Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/lsp-plug.in/tk/widgets/base/Widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,11 @@ namespace lsp
*/
bool has_focus() const;

/** Whether this widget needs native keyboard focus.
* @return true if host keyboard shortcuts must be bypassed
*/
virtual bool needs_input_focus() const;

/**
* Make widget being focused
* @return true if widget has been focused, false if widget already had focus or it is impossible
Expand Down
2 changes: 2 additions & 0 deletions include/lsp-plug.in/tk/widgets/simple/Edit.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ namespace lsp
virtual status_t on_change();
virtual status_t on_before_popup(Menu *menu);
virtual status_t on_popup(Menu *menu);

virtual bool needs_input_focus() const override;
};

} /* namespace tk */
Expand Down
5 changes: 5 additions & 0 deletions src/main/widgets/base/Widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,11 @@ namespace lsp
return (wnd != NULL) ? wnd->check_focus(_this) : false;
}

bool Widget::needs_input_focus() const
{
return false;
}

bool Widget::take_focus()
{
Window *wnd = widget_cast<Window>(toplevel());
Expand Down
4 changes: 4 additions & 0 deletions src/main/widgets/containers/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,8 @@ namespace lsp
ev.nType = ws::UIE_FOCUS_IN;
w->handle_event(&ev);
}
if (pWindow != NULL)
pWindow->set_input_focus((pFocused != NULL) && pFocused->needs_input_focus());
return true;
}

Expand All @@ -1363,6 +1365,8 @@ namespace lsp
ev.nType = ws::UIE_FOCUS_OUT;
w->handle_event(&ev);
}
if (pWindow != NULL)
pWindow->set_input_focus(false);
return true;
}

Expand Down
5 changes: 5 additions & 0 deletions src/main/widgets/simple/Edit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,11 @@ namespace lsp
return STATUS_OK;
}

bool Edit::needs_input_focus() const
{
return true;
}

status_t Edit::slot_popup_cut_action(Widget *sender, void *ptr, void *data)
{
Edit *_this = widget_ptrcast<Edit>(ptr);
Expand Down