Recent

Author Topic: Accelerator keys  (Read 23456 times)

Walmir

  • New Member
  • *
  • Posts: 39
Accelerator keys
« on: August 01, 2014, 09:20:10 pm »
Hi,
Except for TMainMenu, the accelerator keys (with ALT) are not functioning in my applications.
I noted that even in Lazarus IDE, they also don't work in some windows.
Is it a bug?

rvk

  • Hero Member
  • *****
  • Posts: 6111
Re: Accelerator keys
« Reply #1 on: August 01, 2014, 09:47:54 pm »
It's hard to say without more information.

If you make a new application and place 2 buttons on the form with &Button and B&utton as caption and write some Showmessage in the onclick's do the Alt+B and Alt+U activate these buttons ?

If they do then there is nothing wrong with the accelerator keys and there is probably something in you're code eating those keys (and we can't help you if we don't know the code).

(And in what windows in the Lazarus IDE are they not working for you exactly?)
« Last Edit: August 01, 2014, 09:55:58 pm by rvk »

BrunoK

  • Sr. Member
  • ****
  • Posts: 452
  • Retired programmer
Re: Accelerator keys
« Reply #2 on: August 02, 2014, 08:56:44 am »
Maybe what  Walmir means is that, for example, in the Lazarus (any version) Search/Replace dialog (Ctrl+F) (see attached .png), pressing :
Alt+R (Replace with) beeps and does nothing,
Alt+C (Case sensitive) beeps and does nothing,
Alt+W (Whole words only) beeps and does nothing,
etc ...

Am I  correct ?

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Accelerator keys
« Reply #3 on: August 02, 2014, 09:09:33 am »
My version does not have the underlined letters and Alt+Anything beeps and does nothing.

Lazarus 1.2.2 r44758 FPC 2.6.4 i386-win32-win32/win64

eric

  • Sr. Member
  • ****
  • Posts: 267
Re: Accelerator keys
« Reply #4 on: August 02, 2014, 09:20:43 am »
All the accelerator keys in the Find/Replace dialog work correctly here (Lazarus 1.2.4, Linux 64-bit, gtk2).

rvk

  • Hero Member
  • *****
  • Posts: 6111
Re: Accelerator keys
« Reply #5 on: August 02, 2014, 09:44:15 am »
Here the underlined character only become visible after pressing the first ALT. But i did notice the Alt-keys all work with the checkbox-fields but they don't work with the radiogroup-options (while these also have underlined characters)

So Ctrl+R brings up the Replace dialog
but after that Alt+e does not choose the radiobutton "From beginning" while the "e" of beginning is underlined. When you use the radiogroup in your own program they too don't work !! So if Walmir meant that the accelerated keys of the radiogroup doesn't work... i can confirm this.

This is on Windows 7 Professional and
Lazarus 1.2.4 r45510 FPC 2.6.4 i386-win32-win32/win64

(And even though the other ALT+checkbox-letters work they do produce a beep)

BrunoK

  • Sr. Member
  • ****
  • Posts: 452
  • Retired programmer
Re: Accelerator keys
« Reply #6 on: August 02, 2014, 10:56:34 am »
Here we are advancing constructively, thank you guys.

So we have different behaviours depending on :
OS : Linux/GTK2 or Windows
Windows : versions of Windows

As to the presentation maybe also in Lazarus :
Tools->Options->Desktop->Language

And maybe also OS Keyboard setup.

So my configuration is
OS         / Version                 / Lazarus        /  Desktop      / Keyboard
Windows / XP Pro 32 bit SP3 / 1.2.4             / Français [fr] / Français [Suisse]

The comment I posted above applies also when I work with Desktop English [en] and Deutsh [de]

Synthesis to this point :
typo    does not have underlined letters -> Questions : Which Windows version ? What is your desktop->langage ?
eric     (Lazarus 1.2.4, Linux 64-bit, gtk2). Everything works. I'll try to update my Linux test machine and see how it works. Maybe it is GTK2 that makes the difference. (Have some difficulty connecting it to my router, I'm pretty dumb with Linux). Still, it would be interesting to know the Desktop language and the configured Keyboard.
rvk      Accelerator keys work for checkboxes on Windows 7 Pro but still beep.
   -> Questions to rvk who has a different mix of behaviour. Which Desktop ? Which keyboard ?

At last we may get to the bottom of that thing, solve it, and put it to rest in a future version of Lazarus.

Regards,
Bruno K

rvk

  • Hero Member
  • *****
  • Posts: 6111
Re: Accelerator keys
« Reply #7 on: August 02, 2014, 12:15:46 pm »
rvk      Accelerator keys work for checkboxes on Windows 7 Pro but still beep.
   -> Questions to rvk who has a different mix of behaviour. Which Desktop ? Which keyboard ?
I always use English OS, English language and US keyboard layout.
Windows 7 professional. Lazarus 1.2.4 r45510 FPC 2.6.4 i386-win32-win32/win64

It gets even weirder...
At home my radiogroup doesn't even react to accelerated keys at all (only with a bleep)
(from Lazarus IDE and my own program).

At work (logged in via RDP) the radiogroup does react although the choice doesn't get selected but the focus does transfer to the chosen option (also with a bleep).

I think i need to download a fresh version of Lazarus to see if it has something to do with recompilation but... yeah... there is definitely something weird going on.

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: Accelerator keys
« Reply #8 on: August 02, 2014, 03:44:38 pm »
My own 2 cents...


For Windows (since Windows 2000), keyboard indicators become visible (i.e. underlined characters) only after having pressing the 'Alt' key at least once.

This is conformed to the standard Windows behaviour (see here for instance: http://blogs.msdn.com/b/oldnewthing/archive/2005/05/03/414317.aspx), and as far as I've tested, Lazarus is OK with that (i.e. UI states correctly processed).

Please note that it can be changed inside the Windows control panel (I guess it's rarely the case).



Invoking control accelerators (i.e. Alt+Letter) always produced a beep in Windows versions of Lazarus (both for IDE and user's programs), even if there is one (or more) valid control.

IMHO this one is clearly a bug, as the beep should be present only when there is no solution for the given Alt+Letter combination.

There is (at least) one bug report about this problem, though it's first main topic is not concerning it: http://bugs.freepascal.org/view.php?id=19223 (see the last note).



There are a few differences between Delphi and Lazarus/FPC concerning the keyboard accelerators processing for some controls (for instance, for GroupBoxes): I guess it's difficult to say if they are bugs or (specific) features. I won't open the debate.



Concerning the Find/Replace dialog taken as a sample, it's working correctly for me with the english version (Windows XP SP3 - Win32 Lazarus 1.2.4/ FPC 2.6.4). And it's also working with RadioGroups.

It's another matter for the french version of the Find/Replace dialog, as too many letters are used for different controls (see capture; letter 'R' is used 3 times for instance). This could sometime falsely lead users think that the keyboard accelerator is not processed.

I guess the differences found (for the common english version, I mean) with the different users could eventually be relative to Windows versions and/or Windows used themes.

rvk

  • Hero Member
  • *****
  • Posts: 6111
Re: Accelerator keys
« Reply #9 on: August 02, 2014, 04:25:24 pm »
It gets even weirder...
At home my radiogroup doesn't even react to accelerated keys at all (only with a bleep)
Ok, scratch that. It's working again (although i don't know why, I think the choice did get focus but i couldn't see the dotted focus-lines around the focused choice because tab did get me to the next control).

However, the behavior for RadioGroup accelerators is not exactly standard in Lazarus (at least for Windows-OS). When pressing an accelerator for a choice in a RadioGroup the choice gets focus but does not get selected. Other programs in Windows do select the selected choice of a RadioGroup-item (besides giving it focus).

Because i don't know what the standard behavior is under Linux (for RadioGroups-items) i'm also not calling this a bug (yet).

There are a few differences between Delphi and Lazarus/FPC concerning the keyboard accelerators processing for some controls (for instance, for GroupBoxes): I guess it's difficult to say if they are bugs or (specific) features. I won't open the debate.
@ChrisF: If i press Alt+e in your example, "From beginning" does not get selected for me. It does get focus but i have to press space to select it. How is that for you? If it doesn't get selected with you, don't you call that a bug?
« Last Edit: August 02, 2014, 04:30:36 pm by rvk »

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: Accelerator keys
« Reply #10 on: August 02, 2014, 04:57:43 pm »
@rvk:
No, my own version of Lazarus doesn't react as yours concerning this trouble. But we don't have the same version of Windows: is it a possible explanation ?

For any kind of radiobutton (even when located inside a radiogroup control), when the corresponding "target" (i.e. the radiobutton with the corresponding keyboard accelerator inside its caption) is reached, it's both selected AND checked.

BTW, your specific (?) trouble is probably the reason of your former results for radiobutton/radiogroup. As a complement to what has been explained above concerning UI, keyboard indicators like focus rectangles are displayed only after having pressed once any tabulation keys (tab, shift-tab, arrow keys ...).

I guessed it was not the case during your first tests. And as for these controls, only the focusing is changed in your case, it seems to you that there is no effect at all. Pressing a tabulation key should correct it (but doesn't solve your "not-checked" trouble).

Please note that these kinds of test concerning UI (both for underlined characters and focus rectangles) could be tricky to make when done directly inside the IDE. AFAIR, the UI states of the IDE is "propagated" to the launched program. So it's preferable to do these kinds of test by directly launching the program outside the Lazarus IDE.

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Accelerator keys
« Reply #11 on: August 02, 2014, 05:41:42 pm »
Apart from the radiobutton accelerator keys not functioning (apart from beeping) on some versions of Windows (which may be realted to theme as much as OS version), note that in the specific case of the IDE Find dialog there is a clash of accelerator key allocations.
If "Replace with" is unchecked there are two "f" accelerators (From cursor, Find button).
If "Replace with" is checked there are two "r" accelerators (Replace with, Replace button).

Probably the dialog got extended or redesigned at some point and these clashes were overlooked.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Accelerator keys
« Reply #12 on: August 02, 2014, 07:46:27 pm »
Yes, there is a lot of overlapped letters on dialog, only the first one is accessible.
« Last Edit: August 02, 2014, 07:53:27 pm by typo »

ChrisF

  • Hero Member
  • *****
  • Posts: 542
Re: Accelerator keys
« Reply #13 on: August 04, 2014, 09:14:52 pm »
I think I've found a starting point explaining (a part of) the differences between our different results concerning the keyboard accelerators trouble: working, not working.

Please, have a look at this bug report: http://bugs.freepascal.org/view.php?id=26562

Feel free to comment and/or add your own test results.


BrunoK

  • Sr. Member
  • ****
  • Posts: 452
  • Retired programmer
Re: Accelerator keys
« Reply #14 on: August 05, 2014, 11:38:38 am »
Back to my previous post, the request for information about :
OS         / Version                 / Lazarus        /  Desktop      / Keyboard
Windows / XP Pro 32 bit SP3 / 1.2.4             / Français [fr] / Français [Suisse]

was not innocent.

Having finally managed to install a lazarus (easy) on a reinstalled linux machine (debian+gtk2, well that installation didn't go so easy ...) I have done some tests.

All the remarks above in the discussion are consistent with the behaviour of the Accelerator characters on various  Windows/LCL widget type's

Summary OS / LCL widget type -> result :
Win XP          / Win32/Win64     -> None works and beeps
Windows 7   / Win32/Win64     -> According to  rvk on August 02, 2014, 12:15:46 pm
                                                     windows 7 seems to behave like GTK2, see below.
Linux            / Gtk                     -> Tested and works like I think it should work except it
                                                     never beeps, at least on my machine, when there
                                                      is no target for the Accelerator character.
Windows      / Gtk                     -> >>>>>>>> Please can someone  test. <<<<<<

QUESTIONS to rvk, Windows 7 : does it beep always when you do Alt+Valid_AccelChar (I think it shouldn't).  Does it beep always when you do Alt+INEXISTENT_AccelChar (I think it should).  Does TLabel.Caption.AccelTargetChar -> FocusControl ?

How it works on GTK, except it never beeps. Tested with Linus/GTK/Laz 1.2.4/Fpc 2.6.4
& in TLabel and TLabel.FocusControl set goes to the FocusControl -> works if the Accel_char has no duplicate (in my test I have a CheckBox with the same Accel_char), probably handled in the Gtk LCL widget set.
TRadioButton's and TCheckBox's -> does (handled within GTK) :
  - if single target      -> set's the focus to the target and does a either a Toggle_ON, default action or Checked:=not Checked for a TCheckBox.
  - more than one target -> set's the focus to the target but takes not action.
The last 2 are logical because one wouldn't have a action automatically executed if there was a conflict.
Since the Accelerators never worked in version of WIN/WIN up to and including XP, having duplicate targets for a single AccelChar, except for the really annoying beep, did not matter much.

Nice to have guys around here willing to tackle that issue so Lazarus will not look amateruish in MS_Windows environment.

For the rest, since LAZ 1.2, everything is so good that I stopped using my, quite old, versions of Delphi.

Links you might follow :
http://forum.lazarus.freepascal.org/index.php/topic,20249.msg116625.html#msg116625
http://forum.lazarus.freepascal.org/index.php/topic,24475.msg147314.html#msg147314
http://bugs.freepascal.org/view.php?id=26523 -> contains, maybe to aggressive, patches that work with MS_WIN/Win on Laz 1.2.4/FPC 2.6.4 (Reversed in my installation for testing purpose) and Laz 1.3/Fpc 2.7.1, fully functional but would need testing for different platforms. Something I haven't figured out is how to just set the focus on TRadioButton without Toggling when there are more than one AccelChar target, but I'll find way.

 

TinyPortal © 2005-2018