Possible workaround for label entry to keep it from breaking global key handler (Linux tested)

This commit is contained in:
Charles J. Cliffe 2020-06-17 22:05:57 -04:00
parent b564a0ddde
commit c5652be141
5 changed files with 22 additions and 42 deletions

View File

@ -105,6 +105,7 @@ BookmarkPanel::BookmarkPanel( wxWindow* parent, wxWindowID id, const wxPoint& po
m_treeView->Connect( wxEVT_COMMAND_TREE_ITEM_MENU, wxTreeEventHandler( BookmarkPanel::onTreeItemMenu ), NULL, this );
m_treeView->Connect( wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( BookmarkPanel::onTreeSelect ), NULL, this );
m_treeView->Connect( wxEVT_COMMAND_TREE_SEL_CHANGING, wxTreeEventHandler( BookmarkPanel::onTreeSelectChanging ), NULL, this );
m_labelText->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( BookmarkPanel::onLabelKillFocus ), NULL, this );
m_labelText->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( BookmarkPanel::onLabelText ), NULL, this );
m_frequencyVal->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( BookmarkPanel::onDoubleClickFreq ), NULL, this );
m_bandwidthVal->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( BookmarkPanel::onDoubleClickBandwidth ), NULL, this );
@ -133,6 +134,7 @@ BookmarkPanel::~BookmarkPanel()
m_treeView->Disconnect( wxEVT_COMMAND_TREE_ITEM_MENU, wxTreeEventHandler( BookmarkPanel::onTreeItemMenu ), NULL, this );
m_treeView->Disconnect( wxEVT_COMMAND_TREE_SEL_CHANGED, wxTreeEventHandler( BookmarkPanel::onTreeSelect ), NULL, this );
m_treeView->Disconnect( wxEVT_COMMAND_TREE_SEL_CHANGING, wxTreeEventHandler( BookmarkPanel::onTreeSelectChanging ), NULL, this );
m_labelText->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( BookmarkPanel::onLabelKillFocus ), NULL, this );
m_labelText->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( BookmarkPanel::onLabelText ), NULL, this );
m_frequencyVal->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( BookmarkPanel::onDoubleClickFreq ), NULL, this );
m_bandwidthVal->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( BookmarkPanel::onDoubleClickBandwidth ), NULL, this );

View File

@ -27,7 +27,7 @@
<property name="ui_table">UI</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Panel" expanded="0">
<object class="Panel" expanded="1">
<property name="aui_managed">0</property>
<property name="aui_manager_style">wxAUI_MGR_DEFAULT</property>
<property name="bg"></property>
@ -52,7 +52,7 @@
<event name="OnEnterWindow">onEnterWindow</event>
<event name="OnLeaveWindow">onLeaveWindow</event>
<event name="OnMotion">onMotion</event>
<object class="wxBoxSizer" expanded="0">
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer1</property>
<property name="orient">wxVERTICAL</property>
@ -325,11 +325,11 @@
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxPanel" expanded="0">
<object class="wxPanel" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
@ -515,6 +515,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnKillFocus">onLabelKillFocus</event>
<event name="OnTextEnter">onLabelText</event>
</object>
</object>
@ -889,11 +890,11 @@
</object>
</object>
</object>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxPanel" expanded="0">
<object class="wxPanel" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>

View File

@ -70,6 +70,7 @@ class BookmarkPanel : public wxPanel
virtual void onTreeItemMenu( wxTreeEvent& event ) { event.Skip(); }
virtual void onTreeSelect( wxTreeEvent& event ) { event.Skip(); }
virtual void onTreeSelectChanging( wxTreeEvent& event ) { event.Skip(); }
virtual void onLabelKillFocus( wxFocusEvent& event ) { event.Skip(); }
virtual void onLabelText( wxCommandEvent& event ) { event.Skip(); }
virtual void onDoubleClickFreq( wxMouseEvent& event ) { event.Skip(); }
virtual void onDoubleClickBandwidth( wxMouseEvent& event ) { event.Skip(); }

View File

@ -146,8 +146,7 @@ BookmarkView::BookmarkView( wxWindow* parent, wxWindowID id, const wxPoint& pos,
bookmarkChoice = nullptr;
dragItem = nullptr;
dragItemId = nullptr;
editingLabel = false;
m_clearSearchButton->Hide();
hideProps();
@ -165,7 +164,6 @@ BookmarkView::~BookmarkView() {
dragItem = nullptr;
dragItemId = nullptr;
editingLabel = false;
visualDragItem = nullptr;
nextEnt = nullptr;
@ -668,9 +666,6 @@ void BookmarkView::onMenuItem(wxCommandEvent& event) {
bool BookmarkView::isMouseInView() {
if (editingLabel) {
return true;
}
if (m_labelText->HasFocus()) {
return true;
}
@ -1171,11 +1166,20 @@ void BookmarkView::onTreeSelectChanging( wxTreeEvent& event ) {
}
void BookmarkView::onLabelKillFocus(wxFocusEvent &event) {
event.Skip();
wxCommandEvent dummyEvt;
onLabelText(dummyEvt);
if (!m_treeView->HasFocus()) { m_treeView->SetFocus(); }
}
void BookmarkView::onLabelText( wxCommandEvent& /* event */ ) {
std::wstring newLabel = m_labelText->GetValue().ToStdWstring();
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
if (curSel != nullptr) {
if (curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
curSel->demod->setDemodulatorUserLabel(newLabel);
@ -1233,9 +1237,6 @@ void BookmarkView::onRemoveActive( wxCommandEvent& /* event */ ) {
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_ACTIVE) {
if (editingLabel) {
return;
}
doRemoveActive(curSel->demod);
}
}
@ -1270,11 +1271,6 @@ void BookmarkView::onStopRecording( wxCommandEvent& /* event */ ) {
void BookmarkView::onRemoveBookmark( wxCommandEvent& /* event */ ) {
if (editingLabel) {
return;
}
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_BOOKMARK) {
@ -1310,11 +1306,6 @@ void BookmarkView::onActivateRecent( wxCommandEvent& /* event */ ) {
void BookmarkView::onRemoveRecent ( wxCommandEvent& /* event */ ) {
if (editingLabel) {
return;
}
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RECENT) {
@ -1328,10 +1319,6 @@ void BookmarkView::onRemoveRecent ( wxCommandEvent& /* event */ ) {
}
void BookmarkView::onClearRecents ( wxCommandEvent& /* event */ ) {
if (editingLabel) {
return;
}
doClearRecents();
}
@ -1347,11 +1334,6 @@ void BookmarkView::onAddGroup( wxCommandEvent& /* event */ ) {
void BookmarkView::onRemoveGroup( wxCommandEvent& /* event */ ) {
if (editingLabel) {
return;
}
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_GROUP) {
@ -1372,11 +1354,6 @@ void BookmarkView::onAddRange( wxCommandEvent& /* event */ ) {
void BookmarkView::onRemoveRange( wxCommandEvent& /* event */ ) {
if (editingLabel) {
return;
}
TreeViewItem *curSel = itemToTVI(m_treeView->GetSelection());
if (curSel && curSel->type == TreeViewItem::TREEVIEW_ITEM_TYPE_RANGE) {

View File

@ -113,6 +113,7 @@ protected:
void onTreeItemMenu( wxTreeEvent& event );
void onTreeSelect( wxTreeEvent& event );
void onTreeSelectChanging( wxTreeEvent& event );
void onLabelKillFocus(wxFocusEvent& event );
void onLabelText( wxCommandEvent& event );
void onDoubleClickFreq( wxMouseEvent& event );
void onDoubleClickBandwidth( wxMouseEvent& event );
@ -180,8 +181,6 @@ protected:
wxTreeItemId dragItemId;
BookmarkViewVisualDragItem *visualDragItem;
bool editingLabel;
// Bookmarks
std::atomic_bool doUpdateBookmarks;
std::set< std::string > doUpdateBookmarkGroup;