diff --git a/twander.py b/twander.py index dc23d61..fca2019 100755 --- a/twander.py +++ b/twander.py @@ -4,7 +4,7 @@ # For Updates See: http://www.tundraware.com/Software/twander PROGNAME = "twander" -RCSID = "$Id: twander.py,v 2.62 2003/01/16 18:32:33 tundra Exp $" +RCSID = "$Id: twander.py,v 2.63 2003/01/16 23:08:02 tundra Exp $" VERSION = RCSID.split()[2] @@ -201,10 +201,17 @@ Button4Mask = (1<<11) Button5Mask = (1<<12) -# Alt Key is OS-dependent +# There are some event bits we don't care about - +# We'll use the following constant to mask them out +# later in the keyboard and mouse handlers. + +DontCareMask = LockMask + +# Some things are OS-dependent if OSNAME == 'nt': AltMask = (1<<17) + DontCareMask |= Mod1Mask # Some versions of Win32 set this when Alt is pressed else: AltMask = Mod1Mask @@ -330,6 +337,7 @@ wBADENVVBL = "Ignoring Line %s.\nEnvironment Variable %s Not Set:\n\n%s" wBADEXE = "Could Not Execute Command:\n\n%s" wBADRHS = "Ignoring Line %s.\nOption Assignment Has Bad Righthand Side:\n\n%s" +wBADSCNUM = "Ignoring Line %s.\nShortcut Number Must Be From 1-12:\n\n%s" wCONFOPEN = "Cannot Open Configuration File:\n%s" wDIRSCREDEF = "Ignoring Line %s.\nDirectory Shortcut Defined More Than Once:\n\n%s" wDUPKEY = "Ignoring Line %s.\nFound Duplicate Command Key '%s':\n\n%s" @@ -669,6 +677,11 @@ if val: UpdateDirMenu(val) + # User specified an invalid shortcut number + else: + WrnMsg(wBADSCNUM % (num, line)) + return + # Process any option variables elif name in UI.OptionsBoolean: @@ -1161,21 +1174,20 @@ def MouseClick(event): - # Some Win32 systems always set Mod1 as well as Alt - # Get rid of this bit, so it doesn't pester us. - - if OSNAME == 'nt': - event.state = event.state & ~Mod1Mask - + event.state &= ~DontCareMask # Kill the bits we don't care about + if event.state == Button3Mask: # Button-3 / No Modifier x, y = UI.DirList.winfo_pointerxy() # Position near mouse PopupMenu(UI.CmdBtn.menu, x, y) # Display Command Menu - elif event.state == (Button3Mask | ShiftMask): # ShiftButton-3 + elif event.state == (Button3Mask | AltMask): # Alt-Button-3 + x, y = UI.DirList.winfo_pointerxy() # Position near mouse + PopupMenu(UI.HistBtn.menu, x, y) # Display Directory Menu + + elif event.state == (Button3Mask | ShiftMask): # Shift-Button-3 x, y = UI.DirList.winfo_pointerxy() # Position near mouse PopupMenu(UI.DirBtn.menu, x, y) # Display Directory Menu - # End Of 'MouseClick() @@ -1185,20 +1197,18 @@ def MouseDblClick(event): - # Some Win32 systems always set Mod1 as well as Alt - # Get rid of this bit, so it doesn't pester us. - - if OSNAME == 'nt': - event.state = event.state & ~Mod1Mask - + event.state &= ~DontCareMask # Kill the bits we don't care about + if event.state == Button1Mask: # Double-Button-2 / No Modifier DirListHandler(event) # Execute selected item - elif event.state == (Button1Mask | ControlMask): # Control-DoubleButton-1 + elif event.state == (Button1Mask | ControlMask): # Control-DblButton-1 KeyBackDir(event) # Move back one directory - elif event.state == (Button3Mask | ControlMask): # Control-DoubleButton-3 - KeyUpDir(event) # Move up one directory + elif event.state == (Button3Mask | ControlMask): # Control-DblButton-3 + KeyUpDir(event) # Move up one directory + + return "break" # End Of 'MouseDblClick() @@ -1232,11 +1242,7 @@ def KeystrokeHandler(event): - # Some Win32 systems always set Mod1 as well as Alt - # Get rid of this bit, so it doesn't pester us. - - if OSNAME == 'nt': - event.state = event.state & ~Mod1Mask + event.state &= ~DontCareMask # Kill the bits we don't care about # Check for, and handle accelerator keys if event.state == AltMask: @@ -1257,7 +1263,8 @@ # Unrecognized - Ignore else: - return + event.state = 0 + return "break" parts = button.winfo_geometry().split('+') # Geometry returned as "WidthxHeight+X+Y" dims = parts[0].split('x') @@ -1284,7 +1291,7 @@ # is the Shift key if not event.char or (event.state and event.state != 1): - return + return # If the key pressed is a command key (i.e., it is in the table of # defined commands), get its associated string and execute the command. @@ -1730,7 +1737,8 @@ LoadDirList(dir) # Inhibit other processing of this keystroke - return "break" + event.state =0 + return # End of 'FuncKeypress()' @@ -2338,7 +2346,6 @@ pass event.char = cmdkey - event.state = 0 KeystrokeHandler(event) # End Of 'CommandMenuSelection()'