Commit 174aa518 authored by mercury233's avatar mercury233 Committed by GitHub

fix selecting item in listbox by keyboard (#22)

parent 00bc783d
...@@ -325,7 +325,7 @@ bool CGUIListBox::OnEvent(const SEvent& event) ...@@ -325,7 +325,7 @@ bool CGUIListBox::OnEvent(const SEvent& event)
LastKeyTime = now; LastKeyTime = now;
// find the selected item, starting at the current selection // find the selected item, starting at the current selection
s32 start = Selected; const s32 start = Selected;
// dont change selection if the key buffer matches the current item // dont change selection if the key buffer matches the current item
if (Selected > -1 && KeyBuffer.size() > 1) if (Selected > -1 && KeyBuffer.size() > 1)
{ {
...@@ -341,7 +341,8 @@ bool CGUIListBox::OnEvent(const SEvent& event) ...@@ -341,7 +341,8 @@ bool CGUIListBox::OnEvent(const SEvent& event)
{ {
if (KeyBuffer.equals_ignore_case(Items[current].text.subString(0,KeyBuffer.size()))) if (KeyBuffer.equals_ignore_case(Items[current].text.subString(0,KeyBuffer.size())))
{ {
if (Parent && Selected != current && !Selecting && !MoveOverSelect) setSelected(current);
if (Parent && start != current && !Selecting && !MoveOverSelect)
{ {
SEvent e; SEvent e;
e.EventType = EET_GUI_EVENT; e.EventType = EET_GUI_EVENT;
...@@ -350,7 +351,6 @@ bool CGUIListBox::OnEvent(const SEvent& event) ...@@ -350,7 +351,6 @@ bool CGUIListBox::OnEvent(const SEvent& event)
e.GUIEvent.EventType = EGET_LISTBOX_CHANGED; e.GUIEvent.EventType = EGET_LISTBOX_CHANGED;
Parent->OnEvent(e); Parent->OnEvent(e);
} }
setSelected(current);
return true; return true;
} }
} }
...@@ -361,9 +361,9 @@ bool CGUIListBox::OnEvent(const SEvent& event) ...@@ -361,9 +361,9 @@ bool CGUIListBox::OnEvent(const SEvent& event)
{ {
if (KeyBuffer.equals_ignore_case(Items[current].text.subString(0,KeyBuffer.size()))) if (KeyBuffer.equals_ignore_case(Items[current].text.subString(0,KeyBuffer.size())))
{ {
if (Parent && Selected != current && !Selecting && !MoveOverSelect) setSelected(current);
if (Parent && start != current && !Selecting && !MoveOverSelect)
{ {
Selected = current;
SEvent e; SEvent e;
e.EventType = EET_GUI_EVENT; e.EventType = EET_GUI_EVENT;
e.GUIEvent.Caller = this; e.GUIEvent.Caller = this;
...@@ -371,7 +371,6 @@ bool CGUIListBox::OnEvent(const SEvent& event) ...@@ -371,7 +371,6 @@ bool CGUIListBox::OnEvent(const SEvent& event)
e.GUIEvent.EventType = EGET_LISTBOX_CHANGED; e.GUIEvent.EventType = EGET_LISTBOX_CHANGED;
Parent->OnEvent(e); Parent->OnEvent(e);
} }
setSelected(current);
return true; return true;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment