Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-10

Gtk2 focus problem with shortcut keys

9 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Brad Campbell

G'day all,

Here is another one.

Create a new form and place a TMainMenu, TEdit and TButton on the form.

Create a File/Quit menu and assign the quit menu the shortcut ctrl+W.

Hook it up. (This is the only piece of code in the project really)

procedure TForm1.MenuQuitClick(Sender: TObject);
begin
   Close;
end;

Now, when the TEdit has focus, the shortcut does not work. The only way to get it to work is click the button (to focus it). Now you can close the form with ctrl-W.

This seems to be prevalent with any component that takes a keyboard input (I noticed it with TSynEdit initially).

v0.9.27 r16943M i386-linux-gtk 2 (beta)

Free Pascal Compiler version 2.2.3 [2008/10/08] for i386 Copyright (c) 1993-2008 by Florian Klaempfl

unit Unit1;
{$mode objfpc}{$H+}
interface

uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,

   SynEdit, Menus, StdCtrls;
type
   { TForm1 }
   TForm1 = class(TForm)
     Button1: TButton;
     Edit1: TEdit;
     MainMenu1: TMainMenu;
     MenuFile: TMenuItem;
     MenuQuit: TMenuItem;
     procedure FormCreate(Sender: TObject);
     procedure MenuQuitClick(Sender: TObject);
   private
     { private declarations }
   public
     { public declarations }
   end;
var
   Form1: TForm1;
implementation

{ TForm1 }

procedure TForm1.MenuQuitClick(Sender: TObject);
begin
   Close;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
end;
initialization
   {$I unit1.lrs}
end.

Regards,
Brad

Dolphins are so intelligent that within a few weeks they can train Americans to stand at the edge of the pool and throw them fish.

Reply by email

Bart
to Brad Campbell: Here is another one. Create a new form and place a TMainMenu, TEdit and TButton on the…

Actually, you might post a note in this bugreport, nobody has confirmed this bug since I posted it.
Once confirmed, changes may improve that the bug gets assigned to some developer.

I tried to see where things go wrong, but I failed hopelessly ;-)

Bart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20081013/1958b1de/attachment.html

Reply by email

Brad Campbell
to Bart
Bart wrote 6 lines
Actually, you might post a note in this bugreport, nobody has confirmed this bug since I posted it. Once confirmed, changes may improve that the bug gets assigned to some developer. I tried to see where things go wrong, but I failed hopelessly ;-)

I've added a note to confirm the bug.

Regards,
Brad

Dolphins are so intelligent that within a few weeks they can train Americans to stand at the edge of the pool and throw them fish.

Reply by email

Brad Campbell
to Bart
Bart wrote 9 lines
On 10/14/08, *Brad Campbell* < <mailto:>> wrote: I've added a note to confirm the bug. Thanks

It occurs to me that this all works perfectly in Lazarus itself. We are simply using the same components. Why does it not work on my test program, yet works perfectly in Lazarus?

Another thing I just noticed is TEdit and TMemo behave differently. The menu accelerator keys work perfectly if a TMemo has focus, but don't work at all if a TEdit has focus.

Investigation continues.

Brad

Dolphins are so intelligent that within a few weeks they can train Americans to stand at the edge of the pool and throw them fish.

Reply by email

Micha Nelissen
to Brad Campbell: Here is another one. Create a new form and place a TMainMenu, TEdit and TButton on the…
Brad Campbell wrote 7 lines
G'day all, Here is another one. Create a new form and place a TMainMenu, TEdit and TButton on the form. Create a File/Quit menu and assign the quit menu the shortcut ctrl+W.

[..]

Now, when the TEdit has focus, the shortcut does not work. The only way to get it to work is click the button (to focus it). Now you can close the form with ctrl-W.

Probably the Gtk2/TEdit implementation handles Ctrl+W specially. It usually means erase previous word before cursor.

Micha

Reply by email

Brad Campbell
to Micha Nelissen
Micha Nelissen wrote 14 lines
Brad Campbell wrote: > G'day all, > > Here is another one. > > Create a new form and place a TMainMenu, TEdit and TButton on the form. > > Create a File/Quit menu and assign the quit menu the shortcut ctrl+W. [..] > Now, when the TEdit has focus, the shortcut does not work. The only way to get it to work is click > the button (to focus it). Now you can close the form with ctrl-W. Probably the Gtk2/TEdit implementation handles Ctrl+W specially. It usually means erase previous word before cursor.

Ok, perhaps I picked a bad example.
I've also tested Ctrl-O / Ctrl-S / F10 / Ctrl-N / Ctrl-Q..

Brad

Dolphins are so intelligent that within a few weeks they can train Americans to stand at the edge of the pool and throw them fish.

Reply by email

Bart
to Micha Nelissen: [..] Probably the Gtk2/TEdit implementation handles Ctrl+W specially. It usually means…
Show quoted text 6 lines
Probably the Gtk2/TEdit implementation handles Ctrl+W specially. It usually means erase previous word before cursor. Micha

See my original report in the bugtracker
(0007306<http://bugs.freepascal.org/view.php?id=7306>): I tested numerous key combinations...

Bart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20081018/9b26e112/attachment.html

Reply by email