[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] Allow opening cell editor with double-click
From: |
Vaclav Slavik |
Subject: |
Re: [lmi] Allow opening cell editor with double-click |
Date: |
Tue, 17 Jan 2012 15:10:58 +0100 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:9.0) Gecko/20111222 Thunderbird/9.0.1 |
Hi,
On 2012-01-06 17:46, Vadim Zeitlin wrote:
> GC> I've suggested Alt-Enter. Ctrl-Enter would be as good.
>
> I agree with Vaclav that they would be bad choices for the general
> purpose control such as wxDVC but I wonder if either of those could
> be used just for LMI. Would doing this be a problem, Vaclav?
Not at all, it can be done:
--
diff --git a/census_view.cpp b/census_view.cpp
index 07f99b5..4df8c6a 100644
--- a/census_view.cpp
+++ b/census_view.cpp
@@ -960,6 +960,8 @@ wxWindow* CensusView::CreateChildWindow()
,wxDV_ROW_LINES | wxDV_MULTIPLE
);
+ list_window_->GetMainWindow()->Bind(wxEVT_CHAR,
&CensusView::UponCharPressed, this);
+
list_window_->AssociateModel(list_model_.get());
// Show headers.
@@ -1745,3 +1747,19 @@ void CensusView::UponPasteCensus(wxCommandEvent&)
LMI_ASSERT(!class_parms().empty());
}
+void CensusView::UponCharPressed(wxKeyEvent& e)
+{
+ // Use Alt+Enter to trigger inline editing in addition to
+ // the standard F2 key.
+ if(WXK_RETURN == e.GetKeyCode() && wxMOD_ALT == e.GetModifiers())
+ {
+ wxDataViewColumn* col = list_window_->GetCurrentColumn();
+ if(col)
+ {
+ list_window_->EditItem(list_window_->GetCurrentItem(), col);
+ return;
+ }
+ }
+
+ e.Skip();
+}
diff --git a/census_view.hpp b/census_view.hpp
index 6ec48fe..3d72413 100644
--- a/census_view.hpp
+++ b/census_view.hpp
@@ -86,6 +86,7 @@ class CensusView
void UponUpdateAlwaysEnabled (wxUpdateUIEvent&);
void UponUpdateSingleSelection (wxUpdateUIEvent&);
void UponUpdateNonemptySelection(wxUpdateUIEvent&);
+ void UponCharPressed (wxKeyEvent&);
bool DoAllCells(mcenum_emission);
--
But this patch depends on these two API-changing changes to wx after 2.9.3:
http://trac.wxwidgets.org/changeset/70375
http://trac.wxwidgets.org/changeset/70377
You could use the following for the main part. It works with 2.9.3, but
it's also a hack that relies on generic wxDVC implementation's details:
--
+ if(WXK_RETURN == e.GetKeyCode() && wxMOD_ALT == e.GetModifiers())
+ {
+ wxKeyEvent e_modified(e);
+ e_modified.m_keyCode = WXK_F2;
+ e_modified.m_altDown = false;
+ if(list_window_->GetMainWindow()->ProcessWindowEvent(e_modified))
+ return;
+ }
--
Regards,
Vaclav