changeset 3004:d86cddc1cd05

primitivus: select the widget even if an other one is selected when the selection comes from an user action: new `user_action` arguments has been added to newWidget to specify when the new widget comes from a direct user action.
author Goffi <goffi@goffi.org>
date Sun, 14 Jul 2019 20:38:34 +0200
parents e624550d5c24
children 595b8857538b
files sat_frontends/primitivus/primitivus sat_frontends/primitivus/xmlui.py
diffstat 2 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/sat_frontends/primitivus/primitivus	Sun Jul 14 16:43:04 2019 +0200
+++ b/sat_frontends/primitivus/primitivus	Sun Jul 14 20:38:34 2019 +0200
@@ -640,10 +640,17 @@
             self.x_notify.sendNotification(message)
 
 
-    def newWidget(self, widget):
+    def newWidget(self, widget, user_action=False):
+        """Method called when a new widget is created
+
+        if suitable, the widget will be displayed
+        @param widget(widget.PrimitivusWidget): created widget
+        @param user_action(bool): if True, the widget has been created following an
+            explicit user action. In this case, the widget may get focus immediately
+        """
         # FIXME: when several widgets are possible (e.g. with :split)
         #        do not replace current widget when self.selected_widget != None
-        if self.selected_widget is None:
+        if user_action or self.selected_widget is None:
             self.selectWidget(widget)
 
     def selectWidget(self, widget):
--- a/sat_frontends/primitivus/xmlui.py	Sun Jul 14 16:43:04 2019 +0200
+++ b/sat_frontends/primitivus/xmlui.py	Sun Jul 14 20:38:34 2019 +0200
@@ -503,7 +503,7 @@
         if show_type == "popup":
             self.host.showPopUp(self, valign=valign)
         elif show_type == "window":
-            self.host.newWidget(self)
+            self.host.newWidget(self, user_action=self.user_action)
         else:
             assert False
         self.host.redraw()