Add wxDataViewEvent::IsEditCancelled() and support for vetoing edit events.
Currently this is only implemented in the generic wxDataViewCtrl, the native GTK/OSX ports should be modified to support this later. Closes #13323. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68307 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
d32fb5f9f4
commit
2a648479df
@ -441,6 +441,7 @@ All (GUI):
|
|||||||
|
|
||||||
- Support float, double and file name values in wxGenericValidator (troelsk).
|
- Support float, double and file name values in wxGenericValidator (troelsk).
|
||||||
- Fix keyboard navigation in wxGrid with hidden columns (ivan_14_32).
|
- Fix keyboard navigation in wxGrid with hidden columns (ivan_14_32).
|
||||||
|
- Add wxDataViewEvent::IsEditCancelled() (Allonii).
|
||||||
|
|
||||||
OSX:
|
OSX:
|
||||||
|
|
||||||
|
@ -763,7 +763,8 @@ public:
|
|||||||
m_column(NULL),
|
m_column(NULL),
|
||||||
m_pos(-1,-1),
|
m_pos(-1,-1),
|
||||||
m_cacheFrom(0),
|
m_cacheFrom(0),
|
||||||
m_cacheTo(0)
|
m_cacheTo(0),
|
||||||
|
m_editCancelled(false)
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
, m_dataObject(NULL),
|
, m_dataObject(NULL),
|
||||||
m_dataBuffer(NULL),
|
m_dataBuffer(NULL),
|
||||||
@ -780,7 +781,8 @@ public:
|
|||||||
m_column(event.m_column),
|
m_column(event.m_column),
|
||||||
m_pos(event.m_pos),
|
m_pos(event.m_pos),
|
||||||
m_cacheFrom(event.m_cacheFrom),
|
m_cacheFrom(event.m_cacheFrom),
|
||||||
m_cacheTo(event.m_cacheTo)
|
m_cacheTo(event.m_cacheTo),
|
||||||
|
m_editCancelled(event.m_editCancelled)
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
, m_dataObject(event.m_dataObject),
|
, m_dataObject(event.m_dataObject),
|
||||||
m_dataFormat(event.m_dataFormat),
|
m_dataFormat(event.m_dataFormat),
|
||||||
@ -801,6 +803,10 @@ public:
|
|||||||
const wxVariant &GetValue() const { return m_value; }
|
const wxVariant &GetValue() const { return m_value; }
|
||||||
void SetValue( const wxVariant &value ) { m_value = value; }
|
void SetValue( const wxVariant &value ) { m_value = value; }
|
||||||
|
|
||||||
|
// for wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE only
|
||||||
|
bool IsEditCancelled() const { return m_editCancelled; }
|
||||||
|
void SetEditCanceled(bool editCancelled) { m_editCancelled = editCancelled; }
|
||||||
|
|
||||||
// for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
|
// for wxEVT_DATAVIEW_COLUMN_HEADER_CLICKED only
|
||||||
void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; }
|
void SetDataViewColumn( wxDataViewColumn *col ) { m_column = col; }
|
||||||
wxDataViewColumn *GetDataViewColumn() const { return m_column; }
|
wxDataViewColumn *GetDataViewColumn() const { return m_column; }
|
||||||
@ -840,6 +846,7 @@ protected:
|
|||||||
wxPoint m_pos;
|
wxPoint m_pos;
|
||||||
int m_cacheFrom;
|
int m_cacheFrom;
|
||||||
int m_cacheTo;
|
int m_cacheTo;
|
||||||
|
bool m_editCancelled;
|
||||||
|
|
||||||
#if wxUSE_DRAG_AND_DROP
|
#if wxUSE_DRAG_AND_DROP
|
||||||
wxDataObject *m_dataObject;
|
wxDataObject *m_dataObject;
|
||||||
|
@ -2715,6 +2715,26 @@ public:
|
|||||||
*/
|
*/
|
||||||
const wxVariant& GetValue() const;
|
const wxVariant& GetValue() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
Can be used to determine whether the new value is going to be accepted
|
||||||
|
in wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE handler.
|
||||||
|
|
||||||
|
Returns @true if editing the item was cancelled or if the user tried to
|
||||||
|
enter an invalid value (refused by wxDataViewRenderer::Validate()). If
|
||||||
|
this method returns @false, it means that the value in the model is
|
||||||
|
about to be changed to the new one.
|
||||||
|
|
||||||
|
Notice that wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE event handler can
|
||||||
|
call wxNotifyEvent::Veto() to prevent this from happening.
|
||||||
|
|
||||||
|
Currently support for setting this field and for vetoing the change is
|
||||||
|
only available in the generic version of wxDataViewCtrl, i.e. under MSW
|
||||||
|
but not GTK nor OS X.
|
||||||
|
|
||||||
|
@since 2.9.3
|
||||||
|
*/
|
||||||
|
bool IsEditCancelled() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets the column index associated with this event.
|
Sets the column index associated with this event.
|
||||||
*/
|
*/
|
||||||
|
@ -763,21 +763,27 @@ bool wxDataViewRendererBase::FinishEditing()
|
|||||||
|
|
||||||
DestroyEditControl();
|
DestroyEditControl();
|
||||||
|
|
||||||
if (!Validate(value))
|
bool isValid = Validate(value);
|
||||||
return false;
|
|
||||||
|
|
||||||
unsigned int col = GetOwner()->GetModelColumn();
|
unsigned int col = GetOwner()->GetModelColumn();
|
||||||
dv_ctrl->GetModel()->ChangeValue(value, m_item, col);
|
|
||||||
|
|
||||||
// Now we should send Editing Done event
|
// Now we should send Editing Done event
|
||||||
wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, dv_ctrl->GetId() );
|
wxDataViewEvent event( wxEVT_COMMAND_DATAVIEW_ITEM_EDITING_DONE, dv_ctrl->GetId() );
|
||||||
event.SetDataViewColumn( GetOwner() );
|
event.SetDataViewColumn( GetOwner() );
|
||||||
event.SetModel( dv_ctrl->GetModel() );
|
event.SetModel( dv_ctrl->GetModel() );
|
||||||
event.SetItem( m_item );
|
event.SetItem( m_item );
|
||||||
|
event.SetValue( value );
|
||||||
|
event.SetColumn( col );
|
||||||
|
event.SetEditCanceled( !isValid );
|
||||||
event.SetEventObject( dv_ctrl );
|
event.SetEventObject( dv_ctrl );
|
||||||
dv_ctrl->GetEventHandler()->ProcessEvent( event );
|
dv_ctrl->GetEventHandler()->ProcessEvent( event );
|
||||||
|
|
||||||
return true;
|
if ( isValid && event.IsAllowed() )
|
||||||
|
{
|
||||||
|
dv_ctrl->GetModel()->ChangeValue(value, m_item, col);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDataViewRendererBase::PrepareForItem(const wxDataViewModel *model,
|
void wxDataViewRendererBase::PrepareForItem(const wxDataViewModel *model,
|
||||||
|
Loading…
Reference in New Issue
Block a user