From f4866cc88d1138255b52b75e9ebd64a75a64a1d6 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 5 Sep 2001 00:43:20 +0000 Subject: [PATCH] make label and frame unclickable by default --- direct/src/gui/DirectButton.py | 1 + direct/src/gui/DirectEntry.py | 1 + direct/src/gui/DirectFrame.py | 1 + direct/src/gui/DirectGuiBase.py | 14 ++++++++++++-- direct/src/gui/DirectLabel.py | 2 ++ 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/direct/src/gui/DirectButton.py b/direct/src/gui/DirectButton.py index 19115b96bf..3598495391 100644 --- a/direct/src/gui/DirectButton.py +++ b/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), diff --git a/direct/src/gui/DirectEntry.py b/direct/src/gui/DirectEntry.py index 6629f7b86a..779e0782e1 100644 --- a/direct/src/gui/DirectEntry.py +++ b/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), diff --git a/direct/src/gui/DirectFrame.py b/direct/src/gui/DirectFrame.py index d345b64692..d983a30e35 100644 --- a/direct/src/gui/DirectFrame.py +++ b/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), diff --git a/direct/src/gui/DirectGuiBase.py b/direct/src/gui/DirectGuiBase.py index 4335648c42..dbb34f4939 100644 --- a/direct/src/gui/DirectGuiBase.py +++ b/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 diff --git a/direct/src/gui/DirectLabel.py b/direct/src/gui/DirectLabel.py index 4763dc5b2a..e37c8ca5b5 100644 --- a/direct/src/gui/DirectLabel.py +++ b/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