I have a Find dialog (not the standard one) which has a Find Next button. When this button is clicked, a TextCtrl in the parent window highlights the result. If Find Next is clicked again, then the TextCtrl highlights the next result. And so on, starting from the beginning again if no results are found.
The Find Next feature works perfectly, and the highlighting works as well. However, my problem is that the highlighting only shows up in the parent window if the Find dialog is closed. For instance, if I have up the Find dialog, and hit “Find Next” three times, the third instance of the query will be highlighted in the TextCtrl, but I can’t see the highlight until I close the Find dialog. Since the Find dialog is modal, the parent window loses its focus - that’s why the highlight can’t be seen, I think.
How can I fix my program so that the user can see the highlighted text in the frame even while there is a modal Find dialog? Should I change the Find dialog to be a child frame?
You can get your application to display the selections by calling
wx.Yield() . You could also make the dialog non-modal.
Personally, I'm a fan of not using dialogs unless necessary to change
preferences (pick one of X, enter in a value, etc.). I've also found
that having a firefox-like find bar at the bottom/top of the window that
is displaying text, to be far more appealing in look and functionality.
Users are no longer required to differentiate finding with any of the
other tasks that they want to perform.
Here's a screenshot of an application that does that kind of thing and
integrates spell checking/correcting functionality on top of it...
The Find Next feature works perfectly, and the highlighting works as well.
However, my problem is that the highlighting only shows up in the parent
window if the Find dialog is closed. For instance, if I have up the Find
dialog, and hit "Find Next" three times, the third instance of the query
will be highlighted in the TextCtrl, but I can't see the highlight until I
close the Find dialog. Since the Find dialog is modal, the parent window
loses its focus - that's why the highlight can't be seen, I think.
How can I fix my program so that the user can see the highlighted text in
the frame even while there is a modal Find dialog? Should I change the Find
dialog to be a child frame?
I have a Find dialog (not the standard one) which has a Find Next button. When this button is clicked, a TextCtrl in the parent window highlights the result. If Find Next is clicked again, then the TextCtrl highlights the next result. And so on, starting from the beginning again if no results are found.
The Find Next feature works perfectly, and the highlighting works as well. However, my problem is that the highlighting only shows up in the parent window if the Find dialog is closed. For instance, if I have up the Find dialog, and hit "Find Next" three times, the third instance of the query will be highlighted in the TextCtrl, but I can't see the highlight until I close the Find dialog. Since the Find dialog is modal, the parent window loses its focus - that's why the highlight can't be seen, I think.
Correct.
How can I fix my program so that the user can see the highlighted text in the frame even while there is a modal Find dialog? Should I change the Find dialog to be a child frame?
The standard find/replace dialog gets around this by not using ShowModal, just Show, on the dialog.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
I have a Find dialog (not the standard one) which has a Find Next
button. When this button is clicked, a TextCtrl in the parent window
highlights the result. If Find Next is clicked again, then the TextCtrl
highlights the next result. And so on, starting from the beginning again
if no results are found.
The Find Next feature works perfectly, and the highlighting works as
well. However, my problem is that the highlighting only shows up in the
parent window if the Find dialog is closed. For instance, if I have up
the Find dialog, and hit “Find Next” three times, the third instance of
the query will be highlighted in the TextCtrl, but I can’t see the
highlight until I close the Find dialog. Since the Find dialog is modal,
the parent window loses its focus - that’s why the highlight can’t be
seen, I think.
Correct.
How can I fix my program so that the user can see the highlighted text
in the frame even while there is a modal Find dialog? Should I change
the Find dialog to be a child frame?
The standard find/replace dialog gets around this by not using
ShowModal, just Show, on the dialog.
–
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!