added help event origin field: indicates if the help was requested using the mouse or from keyboard
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39340 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
851b88c310
commit
b107e8d578
@ -1983,17 +1983,28 @@ private:
|
||||
class WXDLLIMPEXP_CORE wxHelpEvent : public wxCommandEvent
|
||||
{
|
||||
public:
|
||||
// how was this help event generated?
|
||||
enum Origin
|
||||
{
|
||||
Origin_Unknown, // unrecognized event source
|
||||
Origin_Keyboard, // event generated from F1 key press
|
||||
Origin_HelpButton // event from [?] button on the title bar (Windows)
|
||||
};
|
||||
|
||||
wxHelpEvent(wxEventType type = wxEVT_NULL,
|
||||
wxWindowID winid = 0,
|
||||
const wxPoint& pt = wxDefaultPosition)
|
||||
const wxPoint& pt = wxDefaultPosition,
|
||||
Origin origin = Origin_Unknown)
|
||||
: wxCommandEvent(type, winid),
|
||||
m_pos(pt), m_target(), m_link()
|
||||
m_pos(pt),
|
||||
m_origin(GuessOrigin(origin))
|
||||
{ }
|
||||
wxHelpEvent(const wxHelpEvent & event)
|
||||
: wxCommandEvent(event),
|
||||
m_pos(event.m_pos),
|
||||
m_target(event.m_target),
|
||||
m_link(event.m_link)
|
||||
m_link(event.m_link),
|
||||
m_origin(event.m_origin)
|
||||
{ }
|
||||
|
||||
// Position of event (in screen coordinates)
|
||||
@ -2010,10 +2021,19 @@ public:
|
||||
|
||||
virtual wxEvent *Clone() const { return new wxHelpEvent(*this); }
|
||||
|
||||
// optional indication of the event source
|
||||
Origin GetOrigin() const { return m_origin; }
|
||||
void SetOrigin(Origin origin) { m_origin = origin; }
|
||||
|
||||
protected:
|
||||
wxPoint m_pos;
|
||||
wxString m_target;
|
||||
wxString m_link;
|
||||
Origin m_origin;
|
||||
|
||||
// we can try to guess the event origin ourselves, even if none is
|
||||
// specified in the ctor
|
||||
static Origin GuessOrigin(Origin origin);
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxHelpEvent)
|
||||
|
@ -227,7 +227,8 @@ bool wxContextHelp::DispatchEvent(wxWindow* win, const wxPoint& pt)
|
||||
bool eventProcessed = false;
|
||||
while (subjectOfHelp && !eventProcessed)
|
||||
{
|
||||
wxHelpEvent helpEvent(wxEVT_HELP, subjectOfHelp->GetId(), pt) ;
|
||||
wxHelpEvent helpEvent(wxEVT_HELP, subjectOfHelp->GetId(), pt,
|
||||
wxHelpEvent::Origin_HelpButton);
|
||||
helpEvent.SetEventObject(subjectOfHelp);
|
||||
|
||||
eventProcessed = win->GetEventHandler()->ProcessEvent(helpEvent);
|
||||
|
@ -768,6 +768,23 @@ wxChildFocusEvent::wxChildFocusEvent(wxWindow *win)
|
||||
SetEventObject(win);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxHelpEvent
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/* static */
|
||||
wxHelpEvent::Origin wxHelpEvent::GuessOrigin(Origin origin)
|
||||
{
|
||||
if ( origin == Origin_Unknown )
|
||||
{
|
||||
// assume that the event comes from the help button if it's not from
|
||||
// keyboard and that pressing F1 always results in the help event
|
||||
origin = wxGetKeyState(WXK_F1) ? Origin_Keyboard : Origin_HelpButton;
|
||||
}
|
||||
|
||||
return origin;
|
||||
}
|
||||
|
||||
#endif // wxUSE_GUI
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user