Skip to content

Commit

Permalink
Bugs with console fixed. (mitmproxy#2746)
Browse files Browse the repository at this point in the history
Clicking on a tab now focuses it. Fixes mitmproxy#2676.
  • Loading branch information
kajojify authored and mhils committed Jan 4, 2018
1 parent d982dd9 commit 133dd17
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion mitmproxy/tools/console/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@


class StackWidget(urwid.Frame):
def __init__(self, widget, title, focus):
def __init__(self, window, widget, title, focus):
self.is_focused = focus
self.window = window

if title:
header = urwid.AttrWrap(
urwid.Text(title),
Expand All @@ -29,6 +32,11 @@ def __init__(self, widget, title, focus):
header=header
)

def mouse_event(self, size, event, button, col, row, focus):
if event == "mouse press" and button == 1 and not self.is_focused:
self.window.switch()
return super().mouse_event(size, event, button, col, row, focus)

def keypress(self, size, key):
# Make sure that we don't propagate cursor events outside of the widget.
# Otherwise, in a horizontal layout, urwid's Pile would change the focused widget
Expand Down Expand Up @@ -162,6 +170,7 @@ def wrapped(idx):
else:
title = None
return StackWidget(
self,
widget,
title,
self.pane == idx
Expand Down

0 comments on commit 133dd17

Please sign in to comment.