Audacity 3.2.0
Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
ListNavigationEnabled< WindowBase > Class Template Reference

Changes default arrow navigation to behave more list- or table-like. Instead of searching focusable items among children first, list navigation searches for siblings when arrow key is pressed. Tab behaviour stays same. Requires wxWANT_CHARS style flag to be set. More...

#include <ListNavigationEnabled.h>

Inheritance diagram for ListNavigationEnabled< WindowBase >:
[legend]
Collaboration diagram for ListNavigationEnabled< WindowBase >:
[legend]

Public Member Functions

 ListNavigationEnabled ()
 
void SetInTabOrder (bool inTabOrder)
 

Private Member Functions

void SetFocus () override
 
void OnCharHook (wxKeyEvent &evt)
 
void OnKeyDown (wxKeyEvent &evt)
 
void OnNavigationKeyEvent (wxNavigationKeyEvent &evt)
 
bool Destroy () override
 

Private Attributes

bool mInTabOrder { true }
 

Friends

void ListNavigationEnabled_HandleCharHook (wxWindow *self, wxKeyEvent &evt)
 
void ListNavigationEnabled_HandleKeyDown (wxWindow *self, wxKeyEvent &evt)
 
void ListNavigationEnabled_HandleNavigationKeyEvent (wxWindow *self, wxNavigationKeyEvent &evt, bool inTabOrder)
 
void ListNavigationEnabled_HandleDestroy (wxWindow *self)
 

Detailed Description

template<class WindowBase>
class ListNavigationEnabled< WindowBase >

Changes default arrow navigation to behave more list- or table-like. Instead of searching focusable items among children first, list navigation searches for siblings when arrow key is pressed. Tab behaviour stays same. Requires wxWANT_CHARS style flag to be set.

Definition at line 24 of file ListNavigationEnabled.h.

Constructor & Destructor Documentation

◆ ListNavigationEnabled()

template<class WindowBase >
ListNavigationEnabled< WindowBase >::ListNavigationEnabled ( )
inline

Definition at line 33 of file ListNavigationEnabled.h.

34 {
35 WindowBase::Bind(wxEVT_NAVIGATION_KEY, &ListNavigationEnabled::OnNavigationKeyEvent, this);
36 WindowBase::Bind(wxEVT_KEY_DOWN, &ListNavigationEnabled::OnKeyDown, this);
37 WindowBase::Bind(wxEVT_CHAR_HOOK, &ListNavigationEnabled::OnCharHook, this);
38 }
void OnCharHook(wxKeyEvent &evt)
void OnKeyDown(wxKeyEvent &evt)
void OnNavigationKeyEvent(wxNavigationKeyEvent &evt)

References ListNavigationEnabled< WindowBase >::OnCharHook(), ListNavigationEnabled< WindowBase >::OnKeyDown(), and ListNavigationEnabled< WindowBase >::OnNavigationKeyEvent().

Here is the call graph for this function:

Member Function Documentation

◆ Destroy()

template<class WindowBase >
bool ListNavigationEnabled< WindowBase >::Destroy ( )
inlineoverrideprivate

Definition at line 64 of file ListNavigationEnabled.h.

65 {
67 return wxNavigationEnabled<WindowBase>::Destroy();
68 }
friend void ListNavigationEnabled_HandleDestroy(wxWindow *self)

References ListNavigationEnabled< WindowBase >::ListNavigationEnabled_HandleDestroy.

◆ OnCharHook()

template<class WindowBase >
void ListNavigationEnabled< WindowBase >::OnCharHook ( wxKeyEvent &  evt)
inlineprivate

Definition at line 49 of file ListNavigationEnabled.h.

50 {
52 }
friend void ListNavigationEnabled_HandleCharHook(wxWindow *self, wxKeyEvent &evt)

References ListNavigationEnabled< WindowBase >::ListNavigationEnabled_HandleCharHook.

Referenced by ListNavigationEnabled< WindowBase >::ListNavigationEnabled().

Here is the caller graph for this function:

◆ OnKeyDown()

template<class WindowBase >
void ListNavigationEnabled< WindowBase >::OnKeyDown ( wxKeyEvent &  evt)
inlineprivate

Definition at line 54 of file ListNavigationEnabled.h.

55 {
57 }
friend void ListNavigationEnabled_HandleKeyDown(wxWindow *self, wxKeyEvent &evt)

References ListNavigationEnabled< WindowBase >::ListNavigationEnabled_HandleKeyDown.

Referenced by ListNavigationEnabled< WindowBase >::ListNavigationEnabled().

Here is the caller graph for this function:

◆ OnNavigationKeyEvent()

template<class WindowBase >
void ListNavigationEnabled< WindowBase >::OnNavigationKeyEvent ( wxNavigationKeyEvent &  evt)
inlineprivate

Definition at line 59 of file ListNavigationEnabled.h.

60 {
62 }
friend void ListNavigationEnabled_HandleNavigationKeyEvent(wxWindow *self, wxNavigationKeyEvent &evt, bool inTabOrder)

References ListNavigationEnabled< WindowBase >::ListNavigationEnabled_HandleNavigationKeyEvent, and ListNavigationEnabled< WindowBase >::mInTabOrder.

Referenced by ListNavigationEnabled< WindowBase >::ListNavigationEnabled().

Here is the caller graph for this function:

◆ SetFocus()

template<class WindowBase >
void ListNavigationEnabled< WindowBase >::SetFocus ( )
inlineoverrideprivate

Definition at line 43 of file ListNavigationEnabled.h.

44 {
45 //Prevent attempt to search for a focusable child
47 }
void SetFocus(const WindowPlacement &focus)
Set the window that accepts keyboard input.
Definition: BasicUI.h:392

References BasicUI::SetFocus().

Here is the call graph for this function:

◆ SetInTabOrder()

template<class WindowBase >
void ListNavigationEnabled< WindowBase >::SetInTabOrder ( bool  inTabOrder)
inline

Definition at line 40 of file ListNavigationEnabled.h.

40{ mInTabOrder = inTabOrder; }

References ListNavigationEnabled< WindowBase >::mInTabOrder.

Friends And Related Function Documentation

◆ ListNavigationEnabled_HandleCharHook

template<class WindowBase >
void ListNavigationEnabled_HandleCharHook ( wxWindow *  self,
wxKeyEvent &  evt 
)
friend

Definition at line 13 of file ListNavigationEnabled.cpp.

14{
15 //We want to restore focus to list item once arrow navigation is used
16 //on the child item, for this we need a char hook since key/navigation
17 //events are sent directly to the focused item
18 const auto keyCode = evt.GetKeyCode();
19 if((keyCode == WXK_DOWN || keyCode == WXK_UP) &&
20 !self->HasFocus() &&
21 self->IsDescendant(wxWindow::FindFocus()))
22 {
23 self->SetFocusFromKbd();
24 }
25 else
26 evt.Skip();
27}
std::unique_ptr< WindowPlacement > FindFocus()
Find the window that is accepting keyboard input, if any.
Definition: BasicUI.h:383

Referenced by ListNavigationEnabled< WindowBase >::OnCharHook().

◆ ListNavigationEnabled_HandleDestroy

template<class WindowBase >
void ListNavigationEnabled_HandleDestroy ( wxWindow *  self)
friend

Definition at line 73 of file ListNavigationEnabled.cpp.

74{
75 if(self->IsDescendant(wxWindow::FindFocus()))
76 {
77 auto next = self->GetNextSibling();
78 if(next != nullptr && next->AcceptsFocus())
79 next->SetFocus();
80 else
81 {
82 auto prev = self->GetPrevSibling();
83 if(prev != nullptr && prev->AcceptsFocus())
84 prev->SetFocus();
85 }
86 }
87}

Referenced by ListNavigationEnabled< WindowBase >::Destroy().

◆ ListNavigationEnabled_HandleKeyDown

template<class WindowBase >
void ListNavigationEnabled_HandleKeyDown ( wxWindow *  self,
wxKeyEvent &  evt 
)
friend

Definition at line 29 of file ListNavigationEnabled.cpp.

30{
31 const auto keyCode = evt.GetKeyCode();
32 if(keyCode == WXK_TAB)
33 self->NavigateIn(wxNavigationKeyEvent::FromTab | (evt.ShiftDown() ? wxNavigationKeyEvent::IsBackward : wxNavigationKeyEvent::IsForward));
34 else if(keyCode == WXK_DOWN)
35 self->Navigate(wxNavigationKeyEvent::IsForward);
36 else if(keyCode == WXK_UP)
37 self->Navigate(wxNavigationKeyEvent::IsBackward);
38 else
39 evt.Skip();
40}

Referenced by ListNavigationEnabled< WindowBase >::OnKeyDown().

◆ ListNavigationEnabled_HandleNavigationKeyEvent

template<class WindowBase >
void ListNavigationEnabled_HandleNavigationKeyEvent ( wxWindow *  self,
wxNavigationKeyEvent &  evt,
bool  inTabOrder 
)
friend

Definition at line 42 of file ListNavigationEnabled.cpp.

44{
45 if(evt.GetEventObject() == self->GetParent() && (!evt.IsFromTab() || inTabOrder))
46 self->SetFocusFromKbd();
47 else if(evt.GetEventObject() == self && evt.GetCurrentFocus() == self && evt.IsFromTab())
48 {
49 //NavigateIn
50 wxPropagationDisabler disableProp(evt);
51 const auto isForward = evt.GetDirection();
52 const auto& children = self->GetChildren();
53 auto node = isForward ? children.GetFirst() : children.GetLast();
54 while(node)
55 {
56 auto child = node->GetData();
57 if(child->CanAcceptFocusFromKeyboard())
58 {
59 if(!child->GetEventHandler()->ProcessEvent(evt))
60 {
61 child->SetFocusFromKbd();
62 }
63 evt.Skip(false);
64 return;
65 }
66 node = isForward ? node->GetNext() : node->GetPrevious();
67 }
68 }
69 else
70 evt.Skip();
71}

Referenced by ListNavigationEnabled< WindowBase >::OnNavigationKeyEvent().

Member Data Documentation

◆ mInTabOrder

template<class WindowBase >
bool ListNavigationEnabled< WindowBase >::mInTabOrder { true }
private

The documentation for this class was generated from the following file: