Skip to content

Commit

Permalink
add a 'window' mode to the popup view
Browse files Browse the repository at this point in the history
this mode allows popup windows which do not stay on top of all the
windows on the desktop, they only stay on top of their parent.
  • Loading branch information
sccolbert committed Sep 29, 2013
1 parent 62f0cff commit f37263f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
2 changes: 1 addition & 1 deletion enaml/qt/q_popup_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ def mousePressEvent(self, event):
if not path.isEmpty() and not path.contains(pos):
event.accept()
self.close()
elif win_type == Qt.ToolTip:
elif win_type == Qt.ToolTip or win_type == Qt.Window:
if path.isEmpty() or path.contains(pos):
event.accept()
self.close()
Expand Down
1 change: 1 addition & 0 deletions enaml/qt/qt_popup_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
WINDOW_TYPES = {
'popup': Qt.Popup,
'tool_tip': Qt.ToolTip,
'window': Qt.Window,
}


Expand Down
27 changes: 19 additions & 8 deletions enaml/widgets/popup_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,24 @@ class PopupView(Widget):
#: reference to a transient popup.
popup_views = []

#: The type of the window to create. A 'popup' window will close
#: when the user presses escape or clicks outside of the window.
#: A 'tool_tip' window will close when the user clicks the window.
#: The popup window is useful for showing configuration dialogs,
#: while the tool tip window is useful for notification messages.
#: The window type cannot be changed once the widget is created.
window_type = d_(Enum('popup', 'tool_tip'))
#: The type of the window to create. Each has different behavior. The
#: window type cannot be changed after the widget is created.
#:
#: 'popup'
#: This window will close when the user presses escape or clicks
#: outside of the window. It will block all external interactions
#: until it is closed.
#:
#: 'tool_tip'
#: This window will close when the user clicks inside the window.
#: It stays on top of all the other windows on the desktop. It is
#: useful for showing mouse cursor or desktop notifications.
#:
#: 'window'
#: This window will close when the user clicks inside the window.
#: It stays on top of its parent, but not the other windows on
#: the desktop. It is useful for notifications inside a window.
window_type = d_(Enum('popup', 'tool_tip', 'window'))

#: The mode to use for anchoring. The 'parent' mode uses a point
#: on the parent or the desktop as the target anchor, the 'cursor'
Expand Down Expand Up @@ -153,7 +164,7 @@ class PopupView(Widget):

#: Whether or not close the popup view on a mouse click. For 'popup'
#: windows, this means clicking outside of the view. For 'tool_tip'
#: windows, this means clicking inside of the view.
#: and 'window' windows, this means clicking inside of the view.
close_on_click = d_(Bool(True))

#: Whether or not the background of the popup view is translucent.
Expand Down
2 changes: 1 addition & 1 deletion examples/widgets/popup_view.enaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ enamldef Main(Window): win:
clicked :: ConfigPopup(self).show()
PushButton:
text = 'Show Window Notification'
clicked :: NotificationPopup(win).show()
clicked :: NotificationPopup(win, window_type='window').show()
PushButton:
text = 'Show Desktop Notification'
clicked :: NotificationPopup().show()
Expand Down

0 comments on commit f37263f

Please sign in to comment.