MCPcopy Create free account
hub / github.com/MyGUI/mygui / onKeyButtonPressed

Method onKeyButtonPressed

MyGUIEngine/src/MyGUI_ListBox.cpp:70–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68 }
69
70 void ListBox::onKeyButtonPressed(KeyCode _key, Char _char)
71 {
72 if (getItemCount() == 0)
73 {
74 Base::onKeyButtonPressed(_key, _char);
75 eventNotifyItem(this, IBNotifyItemData(ITEM_NONE, IBNotifyItemData::KeyPressed, _key, _char));
76 return;
77 }
78
79 // очень секретный метод, запатентованный механизм движения курсора
80 size_t sel = mIndexSelect;
81
82 if (_key == KeyCode::ArrowUp)
83 {
84 if (sel != 0)
85 {
86 if (sel == ITEM_NONE)
87 sel = 0;
88 else
89 sel--;
90 }
91 }
92 else if (_key == KeyCode::ArrowDown)
93 {
94 if (sel == ITEM_NONE)
95 sel = 0;
96 else
97 sel++;
98
99 if (sel >= getItemCount())
100 {
101 // старое значение
102 sel = mIndexSelect;
103 }
104 }
105 else if (_key == KeyCode::Home)
106 {
107 sel = 0;
108 }
109 else if (_key == KeyCode::End)
110 {
111 sel = getItemCount() - 1;
112 }
113 else if (_key == KeyCode::PageUp)
114 {
115 if (sel != 0)
116 {
117 if (sel == ITEM_NONE)
118 {
119 sel = 0;
120 }
121 else
122 {
123 size_t page = _getClientWidget()->getHeight() / mHeightLine;
124 if (sel <= page)
125 sel = 0;
126 else
127 sel -= page;

Callers

nothing calls this directly

Calls 3

getScrollPositionMethod · 0.80
IBNotifyItemDataFunction · 0.50
getHeightMethod · 0.45

Tested by

no test coverage detected