leo.zhou
2014-02-20 04:06:52 UTC
Hi,
I have an app running in the background and only having an icon on system
status bar. When users plug in certain usb hardware, the main window should
pop up and get user input. I think this behavior is not abrupt and expected
by users. Here's the code.
pMainFrame = new MyFrame;
pMainFrame->Show();
pMainFrame->RequestUserAttention();
void MyFrame::OnActivate(wxActivateEvent& event)
{
if (event.GetActive())
{
wxUIActionSimulator sim;
sim.MouseMove(m_pText->GetScreenPosition() + wxPoint(10, 10));
sim.MouseClick(wxMOUSE_BTN_LEFT);
}
}
void MyFrame::OnShow(wxShowEvent& event)
{
if (event.IsShown())
{
wxUIActionSimulator sim;
sim.MouseMove(m_pText->GetScreenPosition() + wxPoint(10, 10));
sim.MouseClick(wxMOUSE_BTN_LEFT);
}
}
I use wxSTAY_ON_TOP flag to show the window on top, but it doesn't get
activated automatically, so I cannot set focus on textctrl. Move the code
to wxShowEvent handler doesn't work either. Seems that wxUIActionSimulator
only works when my frame has been activated already. Is there a way to
activate my main frame programmingly on Mac OS? Or any tricky way to do so?
Thanks!
Leo
I have an app running in the background and only having an icon on system
status bar. When users plug in certain usb hardware, the main window should
pop up and get user input. I think this behavior is not abrupt and expected
by users. Here's the code.
pMainFrame = new MyFrame;
pMainFrame->Show();
pMainFrame->RequestUserAttention();
void MyFrame::OnActivate(wxActivateEvent& event)
{
if (event.GetActive())
{
wxUIActionSimulator sim;
sim.MouseMove(m_pText->GetScreenPosition() + wxPoint(10, 10));
sim.MouseClick(wxMOUSE_BTN_LEFT);
}
}
void MyFrame::OnShow(wxShowEvent& event)
{
if (event.IsShown())
{
wxUIActionSimulator sim;
sim.MouseMove(m_pText->GetScreenPosition() + wxPoint(10, 10));
sim.MouseClick(wxMOUSE_BTN_LEFT);
}
}
I use wxSTAY_ON_TOP flag to show the window on top, but it doesn't get
activated automatically, so I cannot set focus on textctrl. Move the code
to wxShowEvent handler doesn't work either. Seems that wxUIActionSimulator
only works when my frame has been activated already. Is there a way to
activate my main frame programmingly on Mac OS? Or any tricky way to do so?
Thanks!
Leo
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users