Skip to content

Commit

Permalink
Better handling of keyboard arrows on search window
Browse files Browse the repository at this point in the history
  • Loading branch information
gentakojima committed Oct 9, 2016
1 parent 71054ca commit cb5f504
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions assets/chooser.glade
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.16.1 -->
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.10"/>
<object class="GtkListStore" id="iconstore">
Expand All @@ -21,7 +21,6 @@
<property name="skip_taskbar_hint">True</property>
<property name="urgency_hint">True</property>
<property name="decorated">False</property>
<property name="has_resize_grip">False</property>
<signal name="focus-out-event" handler="onOutFocus" swapped="no"/>
<signal name="key-release-event" handler="onKeyReleased" swapped="no"/>
<child>
Expand Down Expand Up @@ -59,6 +58,7 @@
<property name="item_padding">3</property>
<property name="activate_on_single_click">True</property>
<signal name="item-activated" handler="onIconActivated" swapped="no"/>
<signal name="selection-changed" handler="onSelectionChanged" swapped="no"/>
<child>
<object class="GtkCellRendererPixbuf" id="cellrendererpixbuf1"/>
<attributes>
Expand Down
8 changes: 8 additions & 0 deletions emojione-picker
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def open_search_window(self, w):
return

searchresults = None
selectionChanged = False
class SearchHandler:
def onSearchChanged(self, search):
global searchresults
Expand Down Expand Up @@ -181,11 +182,18 @@ class SearchHandler:
global searchresults
item_response(self, searchresults[int(index.to_string())])
icon.get_parent_window().hide()
def onSelectionChanged(self, data):
global selectionChanged
selectionChanged = True
def onKeyReleased(self, window, event):
global selectionChanged
if event.keyval == Gdk.KEY_Escape:
window.hide()
elif event.keyval == Gdk.KEY_Down:
searchbuilder.get_object("iconview").grab_focus()
elif event.keyval == Gdk.KEY_Up and selectionChanged == False:
searchbuilder.get_object("search").grab_focus()
selectionChanged = False
def onOutFocus(self, window, data):
window.hide()

Expand Down

0 comments on commit cb5f504

Please sign in to comment.