Changeset 3281

Show
Ignore:
Timestamp:
07/26/07 15:29:42 (1 year ago)
Author:
paul
Message:

Added dEvents.InteractiveChange?, which gets raised when a data control's value
has been changed by the user, interactively. Previously, we could only trap
ValueChanged?, which is raised when the value was changed interactively or
programatically. In addition, ValueChanged? is raised when the control's
value gets updated by the DataSource? or DataField? value changing. In short,
when you catch ValueChanged? you have no idea what the source of the change
is. With InteractiveChange?, you know it was from user input.

I've only tested this with dTextBox, but in theory it should work with all
data controls.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/dEvents.py

    r3222 r3281  
    784784    appliesToClass = classmethod(appliesToClass) 
    785785 
     786class InteractiveChange(dEvent): 
     787    """Occurs when the user interactively changes the control's value.""" 
     788    def appliesToClass(eventClass, objectClass): 
     789        return issubclass(objectClass, dabo.ui.dDataControlMixin) 
     790    appliesToClass = classmethod(appliesToClass) 
     791 
    786792 
    787793class Update(dEvent): 
  • trunk/dabo/ui/dDataControlMixinBase.py

    r3231 r3281  
    1717        self._designerMode = None 
    1818        self._oldVal = None 
     19        self._userChanged = False 
    1920 
    2021        dabo.ui.dControlMixin.__init__(self, *args, **kwargs) 
     
    163164        isChanged = False 
    164165        oldVal = self._oldVal 
     166 
     167        if self._userChanged: 
     168            self.raiseEvent(dabo.dEvents.InteractiveChange, oldVal=oldVal) 
     169            self._userChanged = False 
     170         
    165171        if oldVal is None and curVal is None: 
    166172            # Could be changed and we just don't know it... 
  • trunk/dabo/ui/uiwx/dDataControlMixin.py

    r3199 r3281  
    77 
    88class dDataControlMixin(dDataControlMixinBase): 
     9    def _onWxHit(self, evt, *args, **kwargs): 
     10        self._userChanged = True  ## set the dirty flag so that InteractiveChange can be raised. 
     11        super(dDataControlMixin, self)._onWxHit(evt, *args, **kwargs) 
     12 
     13 
    914    def select(self, position, length): 
    1015        """ Select all text from <position> for <length> or end of string."""