Dialog window question


#1

I just created a dialog box with some text and an “OK” button, but wasn’t sure how to have the dialog close when the OK button was clicked.

I ended up calling getParentComponent()->setVisible(false), which works, but I wasn’t sure if there was a better way to do this. Should my component communicate with the dialog window in a more elegant way?


#2

Depends how you’re using it, and how you’re planning on deleting it.

If it’s modal, you could use exitModalState(), but setVisible (false) will do the same thing indirectly.


#3

An unrelated follow-up: is there a way to set a button as the default button, so that if there are two choices (OK,cancel) one is highlighted, so the user knows that button will respond to the return key?


#4

Just use grabKeyboardFocus() on it when the dialog is started, or check out the keyboard focus order stuff in Component.


#5

Hi Jules,

what do you mean when a “dialog is started”? you mean in the costructor? is there is a virtual method which’s called when doalog is shown?

thanks


#6

Well, I guess you could put that in the constructor, as long as the dialog has already been made visible by that point.


#7