66
69
m_CurrentMenu->Dispose ();
72
void ComboBoxSimple::DoSetFocused (bool focused)
74
View::DoSetFocused (focused);
78
// we need to grab focus control from our parent layout
79
// so that we can handle the key inputs ourself
80
Area *_parent = GetParentObject();
84
if (_parent->IsView ())
86
View *parent = (View*)_parent;
87
parent->SetFocusControl (false);
89
else if (_parent->IsLayout ())
91
Layout *parent = (Layout *)_parent;
92
parent->SetFocusControl (false);
69
98
long ComboBoxSimple::ProcessEvent (IEvent &ievent, long TraverseInfo, long ProcessEventInfo)
71
100
long ret = TraverseInfo;
126
/* must do focus processing after sending events to children */
127
if (ievent.e_event == NUX_KEYDOWN && GetFocused () && m_block_focus == false)
129
FocusDirection direction;
132
direction = FOCUS_DIRECTION_NONE;
134
type = Focusable::GetFocusableEventType (ievent.e_event,
138
if (type == FOCUS_EVENT_DIRECTION)
140
if (direction == FOCUS_DIRECTION_PREV || direction == FOCUS_DIRECTION_NEXT ||
141
direction == FOCUS_DIRECTION_LEFT || direction == FOCUS_DIRECTION_RIGHT)
143
// not pressed UP or Down so send focus to our parent layout
144
Area *area = GetParentObject ();
145
// if parent is null return, thats a valid usecase so no warnings.
149
if ( area->IsView() )
151
View *ic = NUX_STATIC_CAST (View *, area );
152
ic->SetFocusControl (true);
153
ret = ic->ProcessFocusEvent (ievent, ret, ProcessEventInfo);
155
else if ( area->IsLayout() )
157
Layout *layout = NUX_STATIC_CAST (Layout *, area );
158
layout->SetFocusControl (true);
159
ret = layout->ProcessFocusEvent (ievent, ret, ProcessEventInfo);
163
else if (direction == FOCUS_DIRECTION_UP)
166
sigTriggered.emit (this);
167
sigActionTriggered.emit (GetItem (GetSelectionIndex ()));
169
else if (direction == FOCUS_DIRECTION_DOWN)
171
MoveSelectionDown ();
172
sigTriggered.emit (this);
173
sigActionTriggered.emit (GetItem (GetSelectionIndex ()));
178
if (m_block_focus == true)
179
m_block_focus = false;
97
181
ret = PostProcessEvent2 (ievent, ret, ProcessEventInfo);
185
void ComboBoxSimple::MoveSelectionUp ()
187
int current_index = GetSelectionIndex ();
188
SetSelectionIndex (current_index - 1);
191
void ComboBoxSimple::MoveSelectionDown ()
193
int current_index = GetSelectionIndex ();
194
SetSelectionIndex (current_index + 1);
101
197
ActionItem *ComboBoxSimple::AddItem (const TCHAR *label, int Uservalue)
103
199
if (m_CurrentMenu->GetNumItem() == 0)