Fulvio Senore
2009-05-13 09:02:08 UTC
I am using wxWidgets 2.8.9.
I am developing an application that shows a main frame divided in two
panes using a splitter window. The left pane shows a tree control, the
right pane shows a list control or some thumbnails. The user can choose
among different views in the two panes, so I have many windows for the
left pane and many for the right pane: only one is visible at any time,
depending on the user's choice.
I think that this is a rather common layout, so I hope that other people
already had my problem.
The frame has a menubar with some entries: some of them may work on what
is selected in both the left and right pane, so I need to know which is
the last pane clicked by the user. If he clicks the right pane, then he
selects the menu I know that I must process the items selected in the
right pane. Same for the left pane.
I was looking for an elegant way to solve this problem, so I tried this
solution:
bool CMainFrame::RightPaneHasFocus() {
wxWindow *wp = GetCorrectWindowInRightPane();
wxWindow *wpFocus = wxWindow::FindFocus();
return (wp == wpFocus);
}
I get a pointer to the window that is currently shown in the right pane,
I get a pointer from wxWindow::FindFocus() and I check if the pointer
are equal.
This works well in Windows, but not in Linux. In Linux it works well if
I use the menubar, but it does not work if I right-click and choose a
contest menu. Strangely the function call works in the UI update event
handler, but in the "command menu selected" handler
wxWindow::FindFocus() returns null from both the left and right pane.
Is there a workaround for this?
Maybe other people already had this problem, so I would be glad to know
how they solved it.
I know that I could use a flag to trace SetFocus and KillFocus events,
but it would be rather complicated (I think). Those events are handled
in the left and right panes while I need to know which pane is selected
in the main frame. Showing a context menu in wxGTK causes a KillFocus
event so I need another flag to ignore the event if I am showing up the
context menu. At the moment I have 3 windows for the left pane and 6 for
the right pane. I hope that there is a better way.
Thanks in advance for your help.
Fulvio Senore
I am developing an application that shows a main frame divided in two
panes using a splitter window. The left pane shows a tree control, the
right pane shows a list control or some thumbnails. The user can choose
among different views in the two panes, so I have many windows for the
left pane and many for the right pane: only one is visible at any time,
depending on the user's choice.
I think that this is a rather common layout, so I hope that other people
already had my problem.
The frame has a menubar with some entries: some of them may work on what
is selected in both the left and right pane, so I need to know which is
the last pane clicked by the user. If he clicks the right pane, then he
selects the menu I know that I must process the items selected in the
right pane. Same for the left pane.
I was looking for an elegant way to solve this problem, so I tried this
solution:
bool CMainFrame::RightPaneHasFocus() {
wxWindow *wp = GetCorrectWindowInRightPane();
wxWindow *wpFocus = wxWindow::FindFocus();
return (wp == wpFocus);
}
I get a pointer to the window that is currently shown in the right pane,
I get a pointer from wxWindow::FindFocus() and I check if the pointer
are equal.
This works well in Windows, but not in Linux. In Linux it works well if
I use the menubar, but it does not work if I right-click and choose a
contest menu. Strangely the function call works in the UI update event
handler, but in the "command menu selected" handler
wxWindow::FindFocus() returns null from both the left and right pane.
Is there a workaround for this?
Maybe other people already had this problem, so I would be glad to know
how they solved it.
I know that I could use a flag to trace SetFocus and KillFocus events,
but it would be rather complicated (I think). Those events are handled
in the left and right panes while I need to know which pane is selected
in the main frame. Showing a context menu in wxGTK causes a KillFocus
event so I need another flag to ignore the event if I am showing up the
context menu. At the moment I have 3 windows for the left pane and 6 for
the right pane. I hope that there is a better way.
Thanks in advance for your help.
Fulvio Senore