| View previous topic :: View next topic |
| Author |
Message |
WidgetCoder Contributor


Joined: 28 May 2002 Posts: 126 Location: CO, USA
|
Posted: Mon Mar 27, 2006 11:51 pm Post subject: Bitbtn Keyboard Accelerator? |
|
|
Does anyone have a good method of adding a keyboard accelerator to a Bitbtn element they'd be willing to share? Apparently prefixing a character with an ampersand "&" in the button's caption doesn't automatically create a keyboard shortcut. Which is odd since I would assume the Bitbtn was created using a Delphi SpeedButton which utilizes ampersands for marking shortcuts.
Here's a workaround I came up with but it intermittently hangs on the Window Click line (Perhaps a bug in the Window command or more likely my code).
| Code: |
DIALOG CREATE,Test Dialog,-1,0,240,160,RESIZABLE,CLASS TestDlg
DIALOG ADD,STYLE,STYLE1,Tahoma,8,L,,
DIALOG ADD,GROUP,grp1,-2,-4,2000,25,,,STYLE1
DIALOG ADD,BITBTN,FileBtn,0,0,34,22,,&File
DIALOG SHOW
%%WinActive = 1
hotkey add,FileHK,Alt+F
:Resize
:Evloop
wait event,2
goto @event()
:Timer
# Prevent Hotkey from overriding other windows menu accelerators
if @equal(@winactive(C),TestDlg)
if @null(%%WinActive)
# Activate while the window is active
hotkey add,FileHK,Alt+F
%%WinActive = 1
end
else
if %%WinActive
# Deactivate while the window is inactive
hotkey remove,FileHK
%%WinActive =
end
end
goto evloop
:HOTKEY
if @equal(@hotkey(),FileHK)
%W = @winexists(#TestDlg)
%L = @sum(@diff(@winpos(~FileBtn,L),@winpos(%W,L)),17)
%T = @sum(@diff(@winpos(~FileBtn,T),@winpos(%W,T)),20)
Window Click,%W,%L,%T
# Window Click intermittently hangs, doesn't always fire Click Event :(
# In debug (all vars correct) execution will sometimes halt at the
# Window Click line while other times it works just fine.
# Any ideas or suggestions???
end
goto evloop
:FileBtnBUTTON
info File button clicked
goto evloop
:Close
exit
|
Any suggestions? |
|
| Back to top |
|
 |
Skit3000 Admin Team

Joined: 11 May 2002 Posts: 2166 Location: The Netherlands
|
Posted: Wed Mar 29, 2006 8:10 am Post subject: |
|
|
You might try adding an invisible button to your dialog
| Code: | DIALOG CREATE,Test Dialog,-1,0,240,160,RESIZABLE,CLASS TestDlg
DIALOG ADD,STYLE,STYLE1,Tahoma,8,L,,
DIALOG ADD,GROUP,grp1,-2,-4,2000,25,,,STYLE1
DIALOG ADD,BITBTN,FileBtn,0,0,34,22,,&File
DIALOG ADD,BUTTON,FileBtnHotkey,0,0,0,0,&File
DIALOG SHOW
:Resize
:Evloop
wait event
goto @event()
:FileBtnHotkeyBUTTON
:FileBtnBUTTON
info File button clicked
goto evloop
:Close
exit |
_________________ [ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial! |
|
| Back to top |
|
 |
WidgetCoder Contributor


Joined: 28 May 2002 Posts: 126 Location: CO, USA
|
Posted: Wed Mar 29, 2006 5:48 pm Post subject: |
|
|
Wow simple and effective For some reason I always seem to find the longest and most complex solutions first.
Thank you  |
|
| Back to top |
|
 |
WidgetCoder Contributor


Joined: 28 May 2002 Posts: 126 Location: CO, USA
|
Posted: Wed Mar 29, 2006 7:57 pm Post subject: |
|
|
Skit, Using your example I was able to create the desired effect of simulating a menu behavior from BitBtns. I found that using the WINDOW RCLICK command would activate/highlight the button without firing an unnecessary event. This looks a lot better than the standard menu and you can do more with it at runtime.
It works great thanks again..
| Code: |
DIALOG CREATE,Test Dialog,-1,0,240,160,RESIZABLE,CLASS TestDlg
DIALOG ADD,STYLE,STYLE1,Tahoma,8,L,,
DIALOG ADD,GROUP,grp1,-2,-4,2000,25,,,STYLE1
DIALOG ADD,BITBTN,FileBtn,0,0,34,22,,&File
DIALOG ADD,BUTTON,FileBtnHotkey,0,0,0,0,&File
DIALOG SHOW
%%WndID = @winexists(#TestDlg)
:Resize
:Test Item1MENU
:Test Item2MENU
:Evloop
wait event
goto @event()
:FileBtnHotkeyBUTTON
%L = @sum(@diff(@winpos(~FileBtn,L),@winpos(%%WndID,L)),17)
%T = @sum(@diff(@winpos(~FileBtn,T),@winpos(%%WndID,T)),20)
# Right click doesn't generate an event w/Bitbtn so this works
Window Rclick,%%WndID,%L,%T
:FileBtnBUTTON
dialog popup,Test Item1|Test Item2,@winpos(~FileBtn,L),@sum(@winpos(~FileBtn,T),21)
goto evloop
:Close
exit
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|