added wxTreeEvent::GetKeyEvent() to allow to retrieve the key event flags from EVT_TREE_KEY_DOWN event
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11687 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -48,12 +48,32 @@ functions that take a wxTreeEvent argument.
|
|||||||
|
|
||||||
Constructor.
|
Constructor.
|
||||||
|
|
||||||
|
\membersection{wxTreeEvent::GetCode}
|
||||||
|
|
||||||
|
\constfunc{int}{GetCode}{}
|
||||||
|
|
||||||
|
Returns the key code if the event was is a key event. Use
|
||||||
|
\helpref{GetKeyEvent}{wxtreeeventgetkeyevent} to get the values of the
|
||||||
|
modifier keys for this event (i.e. Shift or Ctrl).
|
||||||
|
|
||||||
\membersection{wxTreeEvent::GetItem}
|
\membersection{wxTreeEvent::GetItem}
|
||||||
|
|
||||||
\constfunc{wxTreeItemId}{GetItem}{}
|
\constfunc{wxTreeItemId}{GetItem}{}
|
||||||
|
|
||||||
Returns he item (valid for all events).
|
Returns he item (valid for all events).
|
||||||
|
|
||||||
|
\membersection{wxTreeEvent::GetKeyEvent}\label{wxtreeeventgetkeyevent}
|
||||||
|
|
||||||
|
\constfunc{const wxKeyEvent\&}{GetKeyEvent}{}
|
||||||
|
|
||||||
|
Returns the key event for {\tt EVT\_TREE\_KEY\_DOWN} events.
|
||||||
|
|
||||||
|
\membersection{wxTreeEvent::GetLabel}
|
||||||
|
|
||||||
|
\constfunc{const wxString\&}{GetLabel}{}
|
||||||
|
|
||||||
|
Returns the label if the event was a begin or end edit label event.
|
||||||
|
|
||||||
\membersection{wxTreeEvent::GetOldItem}
|
\membersection{wxTreeEvent::GetOldItem}
|
||||||
|
|
||||||
\constfunc{wxTreeItemId}{GetOldItem}{}
|
\constfunc{wxTreeItemId}{GetOldItem}{}
|
||||||
@@ -66,15 +86,3 @@ Returns the old item index (valid for EVT\_TREE\_ITEM\_CHANGING and CHANGED even
|
|||||||
|
|
||||||
Returns the position of the mouse pointer if the event is a drag event.
|
Returns the position of the mouse pointer if the event is a drag event.
|
||||||
|
|
||||||
\membersection{wxTreeEvent::GetCode}
|
|
||||||
|
|
||||||
\constfunc{int}{GetCode}{}
|
|
||||||
|
|
||||||
The key code if the event was is a key event.
|
|
||||||
|
|
||||||
\membersection{wxTreeEvent::GetLabel}
|
|
||||||
|
|
||||||
\constfunc{const wxString\&}{GetLabel}{}
|
|
||||||
|
|
||||||
Returns the label if the event was a begin or end edit label event.
|
|
||||||
|
|
||||||
|
@@ -435,6 +435,9 @@ protected:
|
|||||||
virtual void DoSetToolTip( wxToolTip *tip );
|
virtual void DoSetToolTip( wxToolTip *tip );
|
||||||
#endif // wxUSE_TOOLTIPS
|
#endif // wxUSE_TOOLTIPS
|
||||||
|
|
||||||
|
// the helper functions used by HandleChar/KeyXXX methods
|
||||||
|
wxKeyEvent CreateKeyEvent(wxEventType evType, int id, WXLPARAM lp) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// common part of all ctors
|
// common part of all ctors
|
||||||
void Init();
|
void Init();
|
||||||
@@ -447,9 +450,6 @@ private:
|
|||||||
bool HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
|
bool HandleNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
|
||||||
#endif // __WIN95__
|
#endif // __WIN95__
|
||||||
|
|
||||||
// the helper functions used by HandleChar/KeyXXX methods
|
|
||||||
wxKeyEvent CreateKeyEvent(wxEventType evType, int id, WXLPARAM lp) const;
|
|
||||||
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxWindowMSW)
|
DECLARE_DYNAMIC_CLASS(wxWindowMSW)
|
||||||
DECLARE_NO_COPY_CLASS(wxWindowMSW)
|
DECLARE_NO_COPY_CLASS(wxWindowMSW)
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
@@ -222,11 +222,6 @@ private:
|
|||||||
|
|
||||||
class WXDLLEXPORT wxTreeEvent : public wxNotifyEvent
|
class WXDLLEXPORT wxTreeEvent : public wxNotifyEvent
|
||||||
{
|
{
|
||||||
friend class WXDLLEXPORT wxTreeCtrl;
|
|
||||||
friend class WXDLLEXPORT wxGenericTreeCtrl;
|
|
||||||
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxTreeEvent);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxTreeEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
|
wxTreeEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
|
||||||
|
|
||||||
@@ -243,19 +238,25 @@ public:
|
|||||||
// wxEVT_COMMAND_TREE_BEGIN_(R)DRAG events only) or click position
|
// wxEVT_COMMAND_TREE_BEGIN_(R)DRAG events only) or click position
|
||||||
wxPoint GetPoint() const { return m_pointDrag; }
|
wxPoint GetPoint() const { return m_pointDrag; }
|
||||||
|
|
||||||
// keyboard code (for wxEVT_COMMAND_TREE_KEY_DOWN only)
|
// keyboard data (for wxEVT_COMMAND_TREE_KEY_DOWN only)
|
||||||
int GetCode() const { return m_code; }
|
const wxKeyEvent& GetKeyEvent() const { return m_evtKey; }
|
||||||
|
int GetCode() const { return m_evtKey.GetKeyCode(); }
|
||||||
|
|
||||||
// label (for EVT_TREE_{BEGIN|END}_LABEL_EDIT only)
|
// label (for EVT_TREE_{BEGIN|END}_LABEL_EDIT only)
|
||||||
const wxString& GetLabel() const { return m_label; }
|
const wxString& GetLabel() const { return m_label; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// we could probably save some space by using union here
|
// not all of the members are used (or initialized) for all events
|
||||||
int m_code;
|
wxKeyEvent m_evtKey;
|
||||||
wxTreeItemId m_item,
|
wxTreeItemId m_item,
|
||||||
m_itemOld;
|
m_itemOld;
|
||||||
wxPoint m_pointDrag;
|
wxPoint m_pointDrag;
|
||||||
wxString m_label;
|
wxString m_label;
|
||||||
|
|
||||||
|
friend class WXDLLEXPORT wxTreeCtrl;
|
||||||
|
friend class WXDLLEXPORT wxGenericTreeCtrl;
|
||||||
|
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxTreeEvent);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef void (wxEvtHandler::*wxTreeEventFunction)(wxTreeEvent&);
|
typedef void (wxEvtHandler::*wxTreeEventFunction)(wxTreeEvent&);
|
||||||
|
@@ -73,7 +73,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent, wxNotifyEvent)
|
|||||||
wxTreeEvent::wxTreeEvent(wxEventType commandType, int id)
|
wxTreeEvent::wxTreeEvent(wxEventType commandType, int id)
|
||||||
: wxNotifyEvent(commandType, id)
|
: wxNotifyEvent(commandType, id)
|
||||||
{
|
{
|
||||||
m_code = 0;
|
|
||||||
m_itemOld = 0l;
|
m_itemOld = 0l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -360,21 +360,6 @@ void wxTreeTextCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
|
|||||||
m_owner->OnRenameAccept();
|
m_owner->OnRenameAccept();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
// wxTreeEvent
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent, wxNotifyEvent)
|
|
||||||
|
|
||||||
wxTreeEvent::wxTreeEvent( wxEventType commandType, int id )
|
|
||||||
: wxNotifyEvent( commandType, id )
|
|
||||||
{
|
|
||||||
m_code = 0;
|
|
||||||
m_itemOld = (wxGenericTreeItem *)NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// wxGenericTreeItem
|
// wxGenericTreeItem
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -2172,7 +2157,7 @@ void wxGenericTreeCtrl::OnKillFocus( wxFocusEvent &event )
|
|||||||
void wxGenericTreeCtrl::OnChar( wxKeyEvent &event )
|
void wxGenericTreeCtrl::OnChar( wxKeyEvent &event )
|
||||||
{
|
{
|
||||||
wxTreeEvent te( wxEVT_COMMAND_TREE_KEY_DOWN, GetId() );
|
wxTreeEvent te( wxEVT_COMMAND_TREE_KEY_DOWN, GetId() );
|
||||||
te.m_code = (int)event.KeyCode();
|
te.m_evtKey = event;
|
||||||
te.SetEventObject( this );
|
te.SetEventObject( this );
|
||||||
if ( GetEventHandler()->ProcessEvent( te ) )
|
if ( GetEventHandler()->ProcessEvent( te ) )
|
||||||
{
|
{
|
||||||
@@ -2236,7 +2221,6 @@ void wxGenericTreeCtrl::OnChar( wxKeyEvent &event )
|
|||||||
{
|
{
|
||||||
wxTreeEvent event( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, GetId() );
|
wxTreeEvent event( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, GetId() );
|
||||||
event.m_item = (long) m_current;
|
event.m_item = (long) m_current;
|
||||||
event.m_code = 0;
|
|
||||||
event.SetEventObject( this );
|
event.SetEventObject( this );
|
||||||
GetEventHandler()->ProcessEvent( event );
|
GetEventHandler()->ProcessEvent( event );
|
||||||
}
|
}
|
||||||
@@ -2661,7 +2645,6 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event )
|
|||||||
{
|
{
|
||||||
wxTreeEvent nevent(wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, GetId());
|
wxTreeEvent nevent(wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, GetId());
|
||||||
nevent.m_item = (long) item;
|
nevent.m_item = (long) item;
|
||||||
nevent.m_code = 0;
|
|
||||||
CalcScrolledPosition(x, y,
|
CalcScrolledPosition(x, y,
|
||||||
&nevent.m_pointDrag.x,
|
&nevent.m_pointDrag.x,
|
||||||
&nevent.m_pointDrag.y);
|
&nevent.m_pointDrag.y);
|
||||||
@@ -2725,7 +2708,6 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event )
|
|||||||
// send activate event first
|
// send activate event first
|
||||||
wxTreeEvent nevent( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, GetId() );
|
wxTreeEvent nevent( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, GetId() );
|
||||||
nevent.m_item = (long) item;
|
nevent.m_item = (long) item;
|
||||||
nevent.m_code = 0;
|
|
||||||
CalcScrolledPosition(x, y,
|
CalcScrolledPosition(x, y,
|
||||||
&nevent.m_pointDrag.x,
|
&nevent.m_pointDrag.x,
|
||||||
&nevent.m_pointDrag.y);
|
&nevent.m_pointDrag.y);
|
||||||
|
@@ -2070,9 +2070,6 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
|
|||||||
}
|
}
|
||||||
|
|
||||||
case TVN_ITEMEXPANDING:
|
case TVN_ITEMEXPANDING:
|
||||||
event.m_code = FALSE;
|
|
||||||
// fall through
|
|
||||||
|
|
||||||
case TVN_ITEMEXPANDED:
|
case TVN_ITEMEXPANDED:
|
||||||
{
|
{
|
||||||
NM_TREEVIEW* tv = (NM_TREEVIEW*)lParam;
|
NM_TREEVIEW* tv = (NM_TREEVIEW*)lParam;
|
||||||
@@ -2104,7 +2101,11 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
|
|||||||
eventType = wxEVT_COMMAND_TREE_KEY_DOWN;
|
eventType = wxEVT_COMMAND_TREE_KEY_DOWN;
|
||||||
TV_KEYDOWN *info = (TV_KEYDOWN *)lParam;
|
TV_KEYDOWN *info = (TV_KEYDOWN *)lParam;
|
||||||
|
|
||||||
event.m_code = wxCharCodeMSWToWX(info->wVKey);
|
// we pass 0 as last CreateKeyEvent() parameter because we
|
||||||
|
// don't have access to the real key press flags here - but as
|
||||||
|
// it is only used to determin wxKeyEvent::m_altDown flag it's
|
||||||
|
// not too bad
|
||||||
|
event.m_evtKey = CreateKeyEvent(wxEVT_KEY_DOWN, info->wVKey, 0);
|
||||||
|
|
||||||
// a separate event for Space/Return
|
// a separate event for Space/Return
|
||||||
if ( !wxIsCtrlDown() && !wxIsShiftDown() &&
|
if ( !wxIsCtrlDown() && !wxIsShiftDown() &&
|
||||||
|
Reference in New Issue
Block a user