浏览代码

make label and frame unclickable by default

David Rose 24 年之前
父节点
当前提交
f4866cc88d

+ 1 - 0
direct/src/gui/DirectButton.py

@@ -27,6 +27,7 @@ class DirectButton(DirectFrame):
             # Define type of DirectGuiWidget
             ('pgFunc',         PGButton,   None),
             ('numStates',      4,          None),
+            ('state',          NORMAL,     None),
             ('invertedFrames', (1,),       None),
             # Command to be called on button click
             ('command',        None,       None),

+ 1 - 0
direct/src/gui/DirectEntry.py

@@ -25,6 +25,7 @@ class DirectEntry(DirectFrame):
             # Define type of DirectGuiWidget
             ('pgFunc',          PGEntry,          None),
             ('numStates',       3,                None),
+            ('state',           NORMAL,           None),
             ('width',           10,               self.setup),
             ('numLines',        5,                self.setup),
             ('focus',           0,                self.setFocus),

+ 1 - 0
direct/src/gui/DirectFrame.py

@@ -15,6 +15,7 @@ class DirectFrame(DirectGuiWidget):
             # Define type of DirectGuiWidget
             ('pgFunc',          PGItem,     None),
             ('numStates',       1,          None),
+            ('state',           self.inactiveInitState, None),
             # Frame can have:
             # A background texture
             ('image',           None,       self.setImage),

+ 12 - 2
direct/src/gui/DirectGuiBase.py

@@ -643,7 +643,17 @@ class DirectGuiWidget(DirectGuiBase, NodePath):
     # Toggle if you wish widget's to snap to grid when draggin
     snapToGrid = 0
     gridSpacing = 0.05
-    
+
+    # Determine the default initial state for inactive (or
+    # unclickable) components.  If we are in edit mode, these are
+    # actually clickable by default.
+    guiEdit = base.config.GetBool('direct-gui-edit', 0)
+    if guiEdit:
+        inactiveInitState = NORMAL
+    else:
+        inactiveInitState = DISABLED
+            
+
     def __init__(self, parent = guiTop, **kw):
         # Direct gui widgets are node paths
         # Direct gui widgets have:
@@ -730,7 +740,7 @@ class DirectGuiWidget(DirectGuiBase, NodePath):
         self.ur = Point3(0)
 
         # Is drag and drop enabled?
-        if base.config.GetBool('direct-gui-edit', 0):
+        if self.guiEdit:
             self.enableEdit()
 
         # Bind destroy hook

+ 2 - 0
direct/src/gui/DirectLabel.py

@@ -16,10 +16,12 @@ class DirectLabel(DirectFrame):
         # The same image/geom/text can be used for all states or each
         # state can have a different text/geom/image
         # State transitions happen under user control
+
         optiondefs = (
             # Define type of DirectGuiWidget
             ('pgFunc',          PGItem,    None),
             ('numStates',       1,         None),
+            ('state',           self.inactiveInitState, None),
             ('activeState',     0,         self.setActiveState),
             )
         # Merge keyword options with default options