Changeset 4272

Show
Ignore:
Timestamp:
07/11/08 00:27:05 (1 month ago)
Author:
paul
Message:

Removed the raising of the ValueError? if you set a menu item Caption in the
form of "Open\tCtrl+O".

Instead, simply override any existing HotKey? with the hotkey provided in
the string, and only set the caption part to the Caption property.

The only potential problem with this is in this example:

item.Caption = "Open\tCtrl+O"
...
item.Caption = "Close"

In this case, the item will still have the Ctrl+O hotkey, and if you
didn't want a hotkey, you'd have to then set it explicitly with:

item.HotKey? = None

I think allowing the shortcut \t format doesn't harm anything, so why not
leave it in. If there's serious disagreement to this, let's give a
DeprecationWarning? instead of the ValueError?, as the \t method was the
only way to set the hotkeys until relatively recently and I know all my
apps use it still - I'm sure there are other apps out there as well.

Paul

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/ui/uiwx/dMenuItem.py

    r4271 r4272  
    8787    def _setCaption(self, val): 
    8888        if self._constructed(): 
    89             if val.count("\t"): 
     89            tabsplit = val.split("\t") 
     90            if len(tabsplit) > 1: 
    9091                # They're using the technique of caption + tab + hotkey 
    91                 raise ValueError, _("Please put HotKey combination in HotKey property.") 
    92             else: 
    93                self._caption = val 
     92                # Override any prior setting of self.HotKey with the new one. 
     93               self._hotKey = tabsplit[1] 
     94            self._caption = tabsplit[0] 
    9495            self._redefine() 
    9596        else: