Re: [wxVTK] picking problem: need SetFocus in OnMouseDown?
Brought to you by:
malat
From: Tim H. <tim...@gm...> - 2007-05-25 13:53:46
|
(Thankyou for the welcome, it's good to be here. After N years of working with MFC I'm finally ditching it for cross-platform tools - and wxWidgets so far seems perfect. Thankyou for writing wxVTK.) I'm on Windows, with the latest wxVTK (1.2), vtk 5.0, wxWidgets 2.8.3. The simplest demonstration I can make of this focus issue is to add this code to the end of MyFrame::MyFrame(..) in the wxVTK "Sample.cpp" sample: this->CreateToolBar(); this->GetToolBar()->AddControl(new wxComboBox(this->GetToolBar(),wxID_ANY,"",wxDefaultPosition, wxDefaultSize,1,&wxString("cat"),wxCB_READONLY)); On my platform, after selecting something from the combo none of the keys work in the VTK window anymore (w, s, p, r, t, etc.) - because the window doesn't have focus, even if you click in it. Adding a call to SetFocus in wxVTKRenderWindowInteractor::OnButtonDown solves the issue nicely. (The symptoms I described before were different because I was using a subclassed vtkInteractorStyle to receive the key presses - and this class received them even if the combo had focus, thus resulting in the coords being returned for the wrong window. But the underlying problem, and the solution, are the same.) EVT_SET_FOCUS messages aren't coming through, except once on initialisation. Hope this helps, Tim On 25/05/07, Mathieu Malaterre <mat...@gm...> wrote: > Hi Tim, > > Welcome to wxVTK ! Glad to see yet another VTK ol'timer on the list :) > Your issue would make -sort of- sense if it was on the Mac. It would > at least be consistent with comments from contrib, see > src/stc/PlatWX.cpp (*). > If you have time, could you check what happen if you implement > OnFocus/EVT_SET_FOCUS for wxVTK with something like cout << "OnFocus > called" > > Thanks > -Mathieu > > > (*) > void OnFocus(wxFocusEvent& event) { > GetParent()->SetFocus(); > event.Skip(); > } > > void OnKillFocus(wxFocusEvent& WXUNUSED(event)) { > // Do nothing. Prevents base class from resetting the colors... > } > > #ifdef __WXMAC__ > // For some reason I don't understand yet the focus doesn't really leave > // the listbox like it should, so if we get any events feed them back to > // the wxSTC > void OnKeyDown(wxKeyEvent& event) { > GetGrandParent()->GetEventHandler()->ProcessEvent(event); > } > void OnChar(wxKeyEvent& event) { > GetGrandParent()->GetEventHandler()->ProcessEvent(event); > } > > // And we need to force the focus back when being destroyed > ~wxSTCListBox() { > GetGrandParent()->SetFocus(); > } > #endif > On 5/25/07, Sander Niemeijer <nie...@st...> wrote: > > Hi Tim, > > > > Which platform are you using? > > > > I know I had to do this explicit SetFocus in > > wxVTKRenderWindowInteractor::OnButtonDown for the Mac Carbon build, > > but as far as I remember it was not necessary for e.g. Linux/GTK. > > > > P.S. The latest version of wxVTK does not have a OnMouseDown, so I > > assume you are actually referring to OnButtonDown. > > > > Best regards, > > Sander Niemeijer > > > > > > On 24-mei-2007, at 13:49, Tim Hutton wrote: > > > > > Hello, > > > > > > When picking in my wxVTK window I sometimes get incorrect results. > > > This happens when I have a toolbar in the same frame window, and one > > > of the toolbar controls has focus. The picked location seems to be > > > vertically offset by the height of the toolbar. > > > > > > I have found that adding a call to SetFocus() near the top of > > > wxVTKRenderWindowInteractor::OnMouseDown() resolves the issue nicely. > > > It makes sense that the render window should get focus when clicked > > > on, I would suggest. > > > > > > Thanks, > > > > > > Tim > > > > > > ---------------------------------------------------------------------- > > > --- > > > This SF.net email is sponsored by DB2 Express > > > Download DB2 Express C - the FREE version of DB2 express and take > > > control of your XML. No limits. Just data. Click to get it now. > > > http://sourceforge.net/powerbar/db2/ > > > _______________________________________________ > > > Wxvtk-users mailing list > > > Wxv...@li... > > > https://lists.sourceforge.net/lists/listinfo/wxvtk-users > > > > > > ------------------------------------------------------------------------- > > This SF.net email is sponsored by DB2 Express > > Download DB2 Express C - the FREE version of DB2 express and take > > control of your XML. No limits. Just data. Click to get it now. > > http://sourceforge.net/powerbar/db2/ > > _______________________________________________ > > Wxvtk-users mailing list > > Wxv...@li... > > https://lists.sourceforge.net/lists/listinfo/wxvtk-users > > > > > -- > Mathieu > -- Tim Hutton - http://www.sq3.org.uk Take the Organic Builder challenge - http://www.sq3.org.uk/Evolution/Squirm3/OrganicBuilder/ |