wheel events lost after dialog

Are you writing your own components and need help with how to set them up or have questions about the components you are deriving from ? Ask them here.
Post Reply
nroberts
Knows some wx things
Knows some wx things
Posts: 44
Joined: Fri Aug 03, 2007 8:07 pm

wheel events lost after dialog

Post by nroberts » Tue Feb 03, 2009 5:50 pm

I am writing a custom drawing editor subclassed from the scrolling window (it seems to be the only way to have scrollbars that function or I would use the simple window class - I'm overriding just about everything in the scrolled window). I'm listening for wheel events using EVT_MOUSEWHEEL. This works just fine until I pop up a text entry dialog in reply to a right click. Once I do this the mouse wheel events never make it to my window though clicks and motion does.

I notice that I lose focus when I bring up the dialog. I commented out all my right click code and just do this:

Code: Select all

  wxWindow * focus1 = wxWindow::FindFocus();
  static std::string const message = "Enter in format \"[x,y]Xz\" to be read as point x,y at zoom level z.";
  static std::string const caption = "Manual alignment.";
  wxTextEntryDialog dlg(window, message, caption);
  if (dlg.ShowModal() == wxID_OK)
  {
    wxWindow * focus2 = wxWindow::FindFocus();
    window->SetFocus();
    wxWindow * focus3 = wxWindow::FindFocus();
    int x = 0;
    ++x; // debug break here to check values.
  }
"window" is a local variable in an event handler. The variable "focus1" matches the pointer value of "window". Both "focus2" and "focus3" appear to contain reference to the text field in the dialog.

What am I doing wrong? What can I do?

Thanks

nroberts
Knows some wx things
Knows some wx things
Posts: 44
Joined: Fri Aug 03, 2007 8:07 pm

Post by nroberts » Tue Feb 03, 2009 6:21 pm

I found a fix for my immediate problem but I think this is going to possibly cause problems in the future when I start adding more widgets to the main app window. What I did is store the text entry dialog on the heap and deleted it before calling SetFocus. If I do that then the call to SetFocus actually does something. If I do not then it does not.

Post Reply