Fixed and clarified editor control event handling
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55903 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -113,20 +113,16 @@ public:
|
|||||||
@remarks
|
@remarks
|
||||||
- Primary control shall use id wxPG_SUBID1, and secondary (button)
|
- Primary control shall use id wxPG_SUBID1, and secondary (button)
|
||||||
control shall use wxPG_SUBID2.
|
control shall use wxPG_SUBID2.
|
||||||
- Implementation shoud use connect all necessary events to the
|
- Implementation shoud connect all necessary events to the
|
||||||
wxPropertyGrid::OnCustomEditorEvent. For Example:
|
wxPropertyGrid::OnCustomEditorEvent. For Example:
|
||||||
@code
|
@code
|
||||||
// Relays wxEVT_COMMAND_TEXT_UPDATED events of primary editor
|
// Relays wxEVT_COMMAND_TEXT_UPDATED events of primary editor
|
||||||
// control to the OnEvent.
|
// control to the OnEvent.
|
||||||
// NOTE: This event in particular is actually automatically
|
propgrid->Connect(control->GetId(), wxEVT_COMMAND_TEXT_UPDATED,
|
||||||
// conveyed, but it is just used as an example.
|
wxCommandEventHandler(wxPropertyGrid::OnCustomEditorEvent));
|
||||||
propgrid->Connect(wxPG_SUBID1, wxEVT_COMMAND_TEXT_UPDATED,
|
|
||||||
wxCommandEventHandler(
|
|
||||||
wxPropertyGrid::OnCustomEditorEvent));
|
|
||||||
@endcode
|
@endcode
|
||||||
OnCustomEditorEvent will then forward events, first to
|
OnCustomEditorEvent will then forward events, first to
|
||||||
wxPGEditor::OnEvent and then to wxPGProperty::OnEvent.
|
wxPGEditor::OnEvent() and then to wxPGProperty::OnEvent().
|
||||||
|
|
||||||
*/
|
*/
|
||||||
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
virtual wxPGWindowList CreateControls(wxPropertyGrid* propgrid,
|
||||||
wxPGProperty* property,
|
wxPGProperty* property,
|
||||||
|
@@ -1792,8 +1792,8 @@ protected:
|
|||||||
|
|
||||||
void DoSetPropertyName( wxPGProperty* p, const wxString& newname );
|
void DoSetPropertyName( wxPGProperty* p, const wxString& newname );
|
||||||
|
|
||||||
// Setups event handling for child control
|
// Sets up basic event handling for child control
|
||||||
void SetupEventHandling( wxWindow* wnd, int id );
|
void SetupChildEventHandling( wxWindow* wnd, int id );
|
||||||
|
|
||||||
void CustomSetCursor( int type, bool override = false );
|
void CustomSetCursor( int type, bool override = false );
|
||||||
|
|
||||||
|
@@ -65,18 +65,16 @@ public:
|
|||||||
@remarks
|
@remarks
|
||||||
- Primary control shall use id wxPG_SUBID1, and secondary (button) control
|
- Primary control shall use id wxPG_SUBID1, and secondary (button) control
|
||||||
shall use wxPG_SUBID2.
|
shall use wxPG_SUBID2.
|
||||||
- Implementation shoud use connect all necessary events to the
|
- Implementation shoud connect all necessary events to the
|
||||||
wxPropertyGrid::OnCustomEditorEvent. For Example:
|
wxPropertyGrid::OnCustomEditorEvent. For Example:
|
||||||
@code
|
@code
|
||||||
// Relays wxEVT_COMMAND_TEXT_UPDATED events of primary editor
|
// Relays wxEVT_COMMAND_TEXT_UPDATED events of primary editor
|
||||||
// control to the OnEvent.
|
// control to the OnEvent.
|
||||||
// NOTE: This event in particular is actually automatically conveyed, but
|
propgrid->Connect(control->GetId(), wxEVT_COMMAND_TEXT_UPDATED,
|
||||||
// it is just used as an example.
|
wxCommandEventHandler(wxPropertyGrid::OnCustomEditorEvent));
|
||||||
propgrid->Connect( wxPG_SUBID1, wxEVT_COMMAND_TEXT_UPDATED,
|
|
||||||
wxCommandEventHandler(wxPropertyGrid::OnCustomEditorEvent) );
|
|
||||||
@endcode
|
@endcode
|
||||||
OnCustomEditorEvent will then forward events, first to wxPGEditor::OnEvent and then to wxPGProperty::OnEvent.
|
OnCustomEditorEvent will then forward events, first to
|
||||||
|
wxPGEditor::OnEvent() and then to wxPGProperty::OnEvent().
|
||||||
*/
|
*/
|
||||||
virtual wxPGWindowList CreateControls( wxPropertyGrid* propgrid, wxPGProperty* property,
|
virtual wxPGWindowList CreateControls( wxPropertyGrid* propgrid, wxPGProperty* property,
|
||||||
const wxPoint& pos, const wxSize& size ) const = 0;
|
const wxPoint& pos, const wxSize& size ) const = 0;
|
||||||
|
@@ -1066,6 +1066,15 @@ wxWindow* wxPGChoiceEditor::CreateControlsBase( wxPropertyGrid* propGrid,
|
|||||||
else
|
else
|
||||||
cb->SetSelection( -1 );
|
cb->SetSelection( -1 );
|
||||||
|
|
||||||
|
// Connect event handling
|
||||||
|
wxWindowID id = cb->GetId();
|
||||||
|
propGrid->Connect(id, wxEVT_COMMAND_COMBOBOX_SELECTED,
|
||||||
|
wxCommandEventHandler(wxPropertyGrid::OnCustomEditorEvent));
|
||||||
|
propGrid->Connect(id, wxEVT_COMMAND_TEXT_UPDATED,
|
||||||
|
wxCommandEventHandler(wxPropertyGrid::OnCustomEditorEvent));
|
||||||
|
propGrid->Connect(id, wxEVT_COMMAND_TEXT_ENTER,
|
||||||
|
wxCommandEventHandler(wxPropertyGrid::OnCustomEditorEvent));
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
cb->Show();
|
cb->Show();
|
||||||
#endif
|
#endif
|
||||||
@@ -1872,6 +1881,7 @@ wxWindow* wxPropertyGrid::GenerateEditorTextCtrl( const wxPoint& pos,
|
|||||||
int extraStyle,
|
int extraStyle,
|
||||||
int maxLen )
|
int maxLen )
|
||||||
{
|
{
|
||||||
|
wxWindowID id = wxPG_SUBID1;
|
||||||
wxPGProperty* selected = m_selected;
|
wxPGProperty* selected = m_selected;
|
||||||
wxASSERT(selected);
|
wxASSERT(selected);
|
||||||
|
|
||||||
@@ -1908,7 +1918,7 @@ wxWindow* wxPropertyGrid::GenerateEditorTextCtrl( const wxPoint& pos,
|
|||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__)
|
||||||
wnd->Hide();
|
wnd->Hide();
|
||||||
#endif
|
#endif
|
||||||
wnd->Create(GetPanel(),wxPG_SUBID1,p,s);
|
wnd->Create(GetPanel(),id,p,s);
|
||||||
|
|
||||||
// This generates rect of the control inside the clipper window
|
// This generates rect of the control inside the clipper window
|
||||||
if ( !hasSpecialSize )
|
if ( !hasSpecialSize )
|
||||||
@@ -1933,7 +1943,7 @@ wxWindow* wxPropertyGrid::GenerateEditorTextCtrl( const wxPoint& pos,
|
|||||||
tc->Hide();
|
tc->Hide();
|
||||||
#endif
|
#endif
|
||||||
SetupTextCtrlValue(value);
|
SetupTextCtrlValue(value);
|
||||||
tc->Create(ctrlParent,wxPG_SUBID1,value, p, s,tcFlags);
|
tc->Create(ctrlParent,id,value, p, s,tcFlags);
|
||||||
|
|
||||||
#if wxPG_NAT_TEXTCTRL_BORDER_ANY
|
#if wxPG_NAT_TEXTCTRL_BORDER_ANY
|
||||||
wxWindow* ed = wnd;
|
wxWindow* ed = wnd;
|
||||||
@@ -1956,6 +1966,13 @@ wxWindow* wxPropertyGrid::GenerateEditorTextCtrl( const wxPoint& pos,
|
|||||||
if ( maxLen > 0 )
|
if ( maxLen > 0 )
|
||||||
tc->SetMaxLength( maxLen );
|
tc->SetMaxLength( maxLen );
|
||||||
|
|
||||||
|
// Connect event handling
|
||||||
|
id = ed->GetId();
|
||||||
|
this->Connect(id, wxEVT_COMMAND_TEXT_UPDATED,
|
||||||
|
wxCommandEventHandler(wxPropertyGrid::OnCustomEditorEvent));
|
||||||
|
this->Connect(id, wxEVT_COMMAND_TEXT_ENTER,
|
||||||
|
wxCommandEventHandler(wxPropertyGrid::OnCustomEditorEvent));
|
||||||
|
|
||||||
return (wxWindow*) ed;
|
return (wxWindow*) ed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1963,6 +1980,7 @@ wxWindow* wxPropertyGrid::GenerateEditorTextCtrl( const wxPoint& pos,
|
|||||||
|
|
||||||
wxWindow* wxPropertyGrid::GenerateEditorButton( const wxPoint& pos, const wxSize& sz )
|
wxWindow* wxPropertyGrid::GenerateEditorButton( const wxPoint& pos, const wxSize& sz )
|
||||||
{
|
{
|
||||||
|
wxWindowID id = wxPG_SUBID2;
|
||||||
wxPGProperty* selected = m_selected;
|
wxPGProperty* selected = m_selected;
|
||||||
wxASSERT(selected);
|
wxASSERT(selected);
|
||||||
|
|
||||||
@@ -1975,7 +1993,7 @@ wxWindow* wxPropertyGrid::GenerateEditorButton( const wxPoint& pos, const wxSize
|
|||||||
wxSize s(25, -1);
|
wxSize s(25, -1);
|
||||||
|
|
||||||
wxButton* but = new wxButton();
|
wxButton* but = new wxButton();
|
||||||
but->Create(GetPanel(),wxPG_SUBID2,wxS("..."),p,s,wxWANTS_CHARS);
|
but->Create(GetPanel(),id,wxS("..."),p,s,wxWANTS_CHARS);
|
||||||
|
|
||||||
// Now that we know the size, move to the correct position
|
// Now that we know the size, move to the correct position
|
||||||
p.x = pos.x + sz.x - but->GetSize().x - 2;
|
p.x = pos.x + sz.x - but->GetSize().x - 2;
|
||||||
@@ -2002,7 +2020,7 @@ wxWindow* wxPropertyGrid::GenerateEditorButton( const wxPoint& pos, const wxSize
|
|||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
but->Hide();
|
but->Hide();
|
||||||
#endif
|
#endif
|
||||||
but->Create(GetPanel(),wxPG_SUBID2,wxS("..."),p,s,wxWANTS_CHARS);
|
but->Create(GetPanel(),id,wxS("..."),p,s,wxWANTS_CHARS);
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
#ifdef __WXGTK__
|
||||||
wxFont font = GetFont();
|
wxFont font = GetFont();
|
||||||
@@ -2016,6 +2034,11 @@ wxWindow* wxPropertyGrid::GenerateEditorButton( const wxPoint& pos, const wxSize
|
|||||||
if ( selected->HasFlag(wxPG_PROP_READONLY) )
|
if ( selected->HasFlag(wxPG_PROP_READONLY) )
|
||||||
but->Disable();
|
but->Disable();
|
||||||
|
|
||||||
|
// Connect event handling
|
||||||
|
id = but->GetId();
|
||||||
|
this->Connect(id, wxEVT_COMMAND_BUTTON_CLICKED,
|
||||||
|
wxCommandEventHandler(wxPropertyGrid::OnCustomEditorEvent));
|
||||||
|
|
||||||
return but;
|
return but;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -499,7 +499,6 @@ BEGIN_EVENT_TABLE(wxPropertyGrid, wxScrolledWindow)
|
|||||||
EVT_CHILD_FOCUS(wxPropertyGrid::OnChildFocusEvent)
|
EVT_CHILD_FOCUS(wxPropertyGrid::OnChildFocusEvent)
|
||||||
EVT_SET_FOCUS(wxPropertyGrid::OnFocusEvent)
|
EVT_SET_FOCUS(wxPropertyGrid::OnFocusEvent)
|
||||||
EVT_KILL_FOCUS(wxPropertyGrid::OnFocusEvent)
|
EVT_KILL_FOCUS(wxPropertyGrid::OnFocusEvent)
|
||||||
EVT_TEXT_ENTER(wxPG_SUBID1,wxPropertyGrid::OnCustomEditorEvent)
|
|
||||||
EVT_SYS_COLOUR_CHANGED(wxPropertyGrid::OnSysColourChanged)
|
EVT_SYS_COLOUR_CHANGED(wxPropertyGrid::OnSysColourChanged)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
@@ -3471,33 +3470,38 @@ void wxPropertyGrid::CustomSetCursor( int type, bool override )
|
|||||||
// wxPropertyGrid property selection
|
// wxPropertyGrid property selection
|
||||||
// -----------------------------------------------------------------------
|
// -----------------------------------------------------------------------
|
||||||
|
|
||||||
#define CONNECT_CHILD(EVT,FUNCTYPE,FUNC) \
|
|
||||||
wnd->Connect(id, EVT, \
|
|
||||||
(wxObjectEventFunction) (wxEventFunction) \
|
|
||||||
FUNCTYPE (&wxPropertyGrid::FUNC), \
|
|
||||||
NULL, this );
|
|
||||||
|
|
||||||
// Setups event handling for child control
|
// Setups event handling for child control
|
||||||
void wxPropertyGrid::SetupEventHandling( wxWindow* argWnd, int id )
|
void wxPropertyGrid::SetupChildEventHandling( wxWindow* argWnd, int id )
|
||||||
{
|
{
|
||||||
wxWindow* wnd = argWnd;
|
wxWindow* wnd = argWnd;
|
||||||
|
|
||||||
if ( argWnd == m_wndEditor )
|
if ( argWnd == m_wndEditor )
|
||||||
{
|
{
|
||||||
CONNECT_CHILD(wxEVT_MOTION,(wxMouseEventFunction),OnMouseMoveChild)
|
this->Connect(id, wxEVT_MOTION,
|
||||||
CONNECT_CHILD(wxEVT_LEFT_UP,(wxMouseEventFunction),OnMouseUpChild)
|
wxMouseEventHandler(wxPropertyGrid::OnMouseMoveChild));
|
||||||
CONNECT_CHILD(wxEVT_LEFT_DOWN,(wxMouseEventFunction),OnMouseClickChild)
|
this->Connect(id, wxEVT_LEFT_UP,
|
||||||
CONNECT_CHILD(wxEVT_RIGHT_UP,(wxMouseEventFunction),OnMouseRightClickChild)
|
wxMouseEventHandler(wxPropertyGrid::OnMouseUpChild));
|
||||||
CONNECT_CHILD(wxEVT_ENTER_WINDOW,(wxMouseEventFunction),OnMouseEntry)
|
this->Connect(id, wxEVT_LEFT_DOWN,
|
||||||
CONNECT_CHILD(wxEVT_LEAVE_WINDOW,(wxMouseEventFunction),OnMouseEntry)
|
wxMouseEventHandler(wxPropertyGrid::OnMouseClickChild));
|
||||||
|
this->Connect(id, wxEVT_RIGHT_UP,
|
||||||
|
wxMouseEventHandler(wxPropertyGrid::OnMouseRightClickChild));
|
||||||
|
this->Connect(id, wxEVT_ENTER_WINDOW,
|
||||||
|
wxMouseEventHandler(wxPropertyGrid::OnMouseEntry));
|
||||||
|
this->Connect(id, wxEVT_LEAVE_WINDOW,
|
||||||
|
wxMouseEventHandler(wxPropertyGrid::OnMouseEntry));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CONNECT_CHILD(wxEVT_NAVIGATION_KEY,(wxNavigationKeyEventFunction),OnNavigationKey)
|
this->Connect(id, wxEVT_NAVIGATION_KEY,
|
||||||
|
wxNavigationKeyEventHandler(wxPropertyGrid::OnNavigationKey));
|
||||||
}
|
}
|
||||||
CONNECT_CHILD(wxEVT_KEY_DOWN,(wxCharEventFunction),OnChildKeyDown)
|
|
||||||
CONNECT_CHILD(wxEVT_KEY_UP,(wxCharEventFunction),OnChildKeyUp)
|
this->Connect(id, wxEVT_KEY_DOWN,
|
||||||
CONNECT_CHILD(wxEVT_KILL_FOCUS,(wxFocusEventFunction),OnFocusEvent)
|
wxKeyEventHandler(wxPropertyGrid::OnChildKeyDown));
|
||||||
|
this->Connect(id, wxEVT_KEY_UP,
|
||||||
|
wxKeyEventHandler(wxPropertyGrid::OnChildKeyUp));
|
||||||
|
this->Connect(id, wxEVT_KILL_FOCUS,
|
||||||
|
wxFocusEventHandler(wxPropertyGrid::OnFocusEvent));
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPropertyGrid::FreeEditors()
|
void wxPropertyGrid::FreeEditors()
|
||||||
@@ -3754,7 +3758,7 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags )
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxWindow* primaryCtrl = GetEditorControl();
|
wxWindow* primaryCtrl = GetEditorControl();
|
||||||
SetupEventHandling(primaryCtrl, wxPG_SUBID1);
|
SetupChildEventHandling(primaryCtrl, wxPG_SUBID1);
|
||||||
|
|
||||||
// Focus and select all (wxTextCtrl, wxComboBox etc)
|
// Focus and select all (wxTextCtrl, wxComboBox etc)
|
||||||
if ( flags & wxPG_SEL_FOCUS )
|
if ( flags & wxPG_SEL_FOCUS )
|
||||||
@@ -3794,7 +3798,7 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags )
|
|||||||
#endif
|
#endif
|
||||||
m_wndEditor2->Show();
|
m_wndEditor2->Show();
|
||||||
|
|
||||||
SetupEventHandling(m_wndEditor2,wxPG_SUBID2);
|
SetupChildEventHandling(m_wndEditor2,wxPG_SUBID2);
|
||||||
|
|
||||||
// If no primary editor, focus to button to allow
|
// If no primary editor, focus to button to allow
|
||||||
// it to interprete ENTER etc.
|
// it to interprete ENTER etc.
|
||||||
|
Reference in New Issue
Block a user