Recent

Author Topic: Accelerator keys  (Read 25350 times)

rvk

  • Hero Member
  • *****
  • Posts: 6890
Re: Accelerator keys
« Reply #30 on: August 12, 2014, 07:51:30 pm »
Someone else can confirm this behavior?
Opposite confirmed.
Here it works correctly.
Do you have a complex form again?
Try it with just a mainform with menu &File which does a showmessage and a button to open a second form.
And a second form with one button &Form which does a showmessage.
It works correctly.

Interesting enough when doing a .Show (instead of a .Showmodal) and focus on the second form opened both events are executed and i don't get a beep.

So when doing a .Show and there is a clash in accelerator keys, the accelerator of the mainmenu will also run without a beep. When doing a .Showmodal i get a beep on that form and the event is executed. (maybe that's where the beep comes from, from a missing mainmenu ;))

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: Accelerator keys
« Reply #31 on: August 12, 2014, 11:13:43 pm »
The beep is coming from the menu handler (i.e. the part of the code which is responsible of finding a corresponding main menu entry for a mnemonic).

Basically, here is the current (improper) process for a mnemonic (i.e. WM_SYSCHAR/WM_MENUCHAR messages):

Code: [Select]
call menuhandler(mnemonic)
   if valid main menu entry for the mnemonic
      call the corresponding main menu entry
   else
      beep
     
call formcontromhandler(mnemonic)
   if valid control for the mnemonic
      call the valid control
   else
      do nothing
     
While the correct process should be instead (to comply with standard Windows rules):

Code: [Select]
call formcontromhandler(mnemonic)
   if valid control for the mnemonic
      call the valid control
   else
      call menuhandler(mnemonic)
         if valid main menu entry for the mnemonic
            call the corresponding main menu entry
         else
            beep
   

I've not included here the additional bug, which is the reason why the formcontromhandler is not always called.

Details of both bugs (i.e. beep then accelerator not processed) can be found in this bug report: http://bugs.freepascal.org/view.php?id=26562

 

TinyPortal © 2005-2018