Skip to content

Commit

Permalink
widgets: WDropDown: When opening dropdown, highlight current item.
Browse files Browse the repository at this point in the history
Previosuly, first item in popup was selected, instead of current.
  • Loading branch information
pfalcon committed Nov 5, 2020
1 parent a202114 commit 3145588
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions picotui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,10 @@ def handle_mouse(self, x, y):
# (Processed) mouse click finishes selection
return ACTION_OK

def __init__(self, x, y, w, h, items):
def __init__(self, x, y, w, h, items, sel_item=0):
super().__init__(x, y, w, h)
self.list = self.OneShotList(w - 2, h - 2, items)
self.list.cur_line = sel_item
self.add(1, 1, self.list)

def handle_mouse(self, x, y):
Expand Down Expand Up @@ -396,7 +397,7 @@ def redraw(self):
self.wr(DOWN_ARROW)

def handle_mouse(self, x, y):
popup = WPopupList(self.x, self.y + 1, self.w, self.dropdown_h, self.items)
popup = WPopupList(self.x, self.y + 1, self.w, self.dropdown_h, self.items, self.choice)
res = popup.loop()
if res == ACTION_OK:
self.choice = popup.get_choice()
Expand Down

0 comments on commit 3145588

Please sign in to comment.