Okay, folks, here’s another one.
As I’ve mentioned before, I’m
all about reducing keystrokes, and my target today is the “back” button. My Visio solutions tend to be intricately cross-hyperlinked, necessitating a lot of back button clicks, so I’d like to try to somehow reduce the effort required to go back. The question is how.
My first solution was a right-click action on the page’s shapesheet, but that required three steps: right click on the background (pretty easy), hunt for the option (not as easy – requires reading the options), then right click on it (not so easy at all – I occasionally misclick and hit a neighboring right-click option). The native Visio back button on the toolbar has the same drawbacks. But why not, I ask myself, just double click on the empty background and call that my back button? Pretty easy, no hunting necessary, and misclicking becomes virtually impossible. The question is how.
The only double click event I could find in Visio is the EventDblClick event on every shape. But what if there’s NO shape? The page shapesheet has no equivalent cell; and although you can add a hyperlink section, it does not respond to double clicking.
One solution I tried was putting one giant, page-sized shape behind everything and using its EventDblClick, but it kept getting in the way and became more trouble than the click-hunt-misclick solutions I already had.
The best I've come up with so far is to handle a simulated double click using the application’s Mouse Down event. Click it once, and it saves the current time in a static variable. Click it again, and if it’s within a second of the first click, do my back processing. Here’s how:
Private Sub X_MouseDown(ByVal Button As Long, ByVal KeyButtonState As Long, ByVal x As Double, ByVal Y As Double, CancelDefault As Boolean)
Dim Selections As Integer
Static StartTime As Date
Selections = ActiveWindow.Selection.Count
If DateDiff("s", StartTime, Time) < 1 Then
If Selections = 0 Then ‘ you know you’re on the background and not on a shape
DoMyBackProcessing
End If
End If
StartTime = Time
End Sub
Yes, it works; but I was looking for something a little more elegant. Any suggestions?
Thanks in advance,
- Ken