forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Bitbtn Keyboard Accelerator?

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
WidgetCoder
Contributor
Contributor


Joined: 28 May 2002
Posts: 126
Location: CO, USA

PostPosted: Mon Mar 27, 2006 11:51 pm    Post subject: Bitbtn Keyboard Accelerator? Reply with quote

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
View user's profile Send private message Send e-mail
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Wed Mar 29, 2006 8:10 am    Post subject: Reply with quote

You might try adding an invisible button to your dialog Smile

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
View user's profile Send private message
WidgetCoder
Contributor
Contributor


Joined: 28 May 2002
Posts: 126
Location: CO, USA

PostPosted: Wed Mar 29, 2006 5:48 pm    Post subject: Reply with quote

Wow simple and effective Worship For some reason I always seem to find the longest and most complex solutions first.

Thank you Exclamation
Back to top
View user's profile Send private message Send e-mail
WidgetCoder
Contributor
Contributor


Joined: 28 May 2002
Posts: 126
Location: CO, USA

PostPosted: Wed Mar 29, 2006 7:57 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
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

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group