Sign in Join

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

Mailing lists / lazarus / 2010-06

GTK2: PostMessage(..., LM_CHAR, ...) and IntfUTF8KeyPress(...)

9 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

Žilvinas Ledas

Hello all,

it's the first time I am trying something with Linux and GTK2 and these two things do not work at all:
1.

  PostMessage(currentEdit.Handle, LM_CHAR, Ord('a'), 0); // trying to

post msg to some TEdit

2.
  UTF8Key := 'a';
  currentEdit.IntfUTF8KeyPress(UTF8Key, 1, false);

Should these code snippets do something, or it is OK that they have no effect? I am using FPC 2.5.1 [2010/06/09] and todays SVN Lazarus on Ubuntu 9.X .

Regards
?ilvinas

Paul Ishenin
to Žilvinas Ledas
?ilvinas Ledas wrote 12 lines
1. PostMessage(currentEdit.Handle, LM_CHAR, Ord('a'), 0); // trying to post msg to some TEdit 2. UTF8Key := 'a'; currentEdit.IntfUTF8KeyPress(UTF8Key, 1, false); Should these code snippets do something, or it is OK that they have no effect? I am using FPC 2.5.1 [2010/06/09] and todays SVN Lazarus on Ubuntu 9.X .

Well, at least they don't emulate key presses if you needed that but they must call the appropriate handlers in the edit component.

Best regards,
Paul Ishenin.

Žilvinas Ledas
to Paul Ishenin
Paul Ishenin wrote 15 lines
29.06.2010 5:13, ?ilvinas Ledas wrote: > 1. > PostMessage(currentEdit.Handle, LM_CHAR, Ord('a'), 0); // trying to > post msg to some TEdit > > 2. > UTF8Key := 'a'; > currentEdit.IntfUTF8KeyPress(UTF8Key, 1, false); > > > Should these code snippets do something, or it is OK that they have > no effect? I am using FPC 2.5.1 [2010/06/09] and todays SVN Lazarus > on Ubuntu 9.X . Well, at least they don't emulate key presses if you needed that but they must call the appropriate handlers in the edit component.

Yes, I needed some kind of emulation :) and I expected it would be so as the message queue is "emulated".
Thanks for answer. I'll try to investigate other possibilities. Or maybe someone can point me to the right direction?

Thanks
?ilvinas

Žilvinas Ledas
to Paul Ishenin: Well, at least they don't emulate key presses if you needed that but they must call the…
Paul Ishenin wrote 16 lines
29.06.2010 5:13, ?ilvinas Ledas wrote: > 1. > PostMessage(currentEdit.Handle, LM_CHAR, Ord('a'), 0); // trying to > post msg to some TEdit > > 2. > UTF8Key := 'a'; > currentEdit.IntfUTF8KeyPress(UTF8Key, 1, false); > > > Should these code snippets do something, or it is OK that they have > no effect? I am using FPC 2.5.1 [2010/06/09] and todays SVN Lazarus > on Ubuntu 9.X . Well, at least they don't emulate key presses if you needed that but they must call the appropriate handlers in the edit component.

By the way, none of KeyPress() KeyUp() dUTF8KeyPress() hanlers are called when PostMessage(currentEdit.Handle, LM_CHAR, Ord('a'), 0); is sent. Is this intended behaviour?

Regards
?ilvinas

Mattias Gaertner
to Žilvinas Ledas
Show quoted text 22 lines
On 2010-06-29 01:57, Paul Ishenin wrote: > 29.06.2010 5:13, ?ilvinas Ledas wrote: >> 1. >> PostMessage(currentEdit.Handle, LM_CHAR, Ord('a'), 0); // trying to >> post msg to some TEdit >> >> 2. >> UTF8Key := 'a'; >> currentEdit.IntfUTF8KeyPress(UTF8Key, 1, false); >> >> >> Should these code snippets do something, or it is OK that they have >> no effect? I am using FPC 2.5.1 [2010/06/09] and todays SVN Lazarus >> on Ubuntu 9.X . > Well, at least they don't emulate key presses if you needed that but > they must call the appropriate handlers in the edit component. > By the way, none of KeyPress() KeyUp() dUTF8KeyPress() hanlers are called when PostMessage(currentEdit.Handle, LM_CHAR, Ord('a'), 0); is sent. Is this intended behaviour?

Yes. LM_CHAR normally triggers OnKeyPress, but TCustomEdit eats that.

Mattias

Michael Schnell
to Žilvinas Ledas: it's the first time I am trying something with Linux and GTK2 and these two things do not…
?ilvinas Ledas wrote
PostMessage(currentEdit.Handle, LM_CHAR, Ord('a'), 0); // trying to post msg to some TEdit

AFAIK, Controls that react on messages is a windows specific way to manage controls.

In Linux, messages can be used to have a thread notify the main thread (that receives the message via the "procedure ...message" construct, but not for managing controls or to send messages to other processes.

-Michael

Žilvinas Ledas
to Michael Schnell
Michael Schnell wrote 15 lines
On 06/28/2010 11:13 PM, ?ilvinas Ledas wrote: > PostMessage(currentEdit.Handle, LM_CHAR, Ord('a'), 0); // trying to > post msg to some TEdit > AFAIK, Controls that react on messages is a windows specific way to manage controls. In Linux, messages can be used to have a thread notify the main thread (that receives the message via the "procedure ...message" construct, but not for managing controls or to send messages to other processes. -Michael

Yes, thanks, I understand that. I just was HOPING it will do what I want :) I have some kind of "virtual keyboard" but it is only for my own app (it does send "keys" to 3 TEdit's), so I was hoping such PostMessage() will work as I expect. As it is not - I will manage to go without it.

Regards
?ilvinas

Paul Ishenin
to Žilvinas Ledas
?ilvinas Ledas wrote
Yes, thanks, I understand that. I just was HOPING it will do what I want :) I have some kind of "virtual keyboard" but it is only for my own app (it does send "keys" to 3 TEdit's), so I was hoping such PostMessage() will work as I expect. As it is not - I will manage to go without it.

During the last year I already heard 3 times about virtual keyboards in Lazarus applications. All the 3 times developers are trying to emulate the real keyboard event. There is no cross-platform way to do this in Lazarus. I know some devels found the way to emulate keyboard events in linux but personaly I would probably choose to manage the controls content in the program instead if there are not too much different control types.

Best regards,
Paul Ishenin.

Žilvinas Ledas
to Paul Ishenin
Paul Ishenin wrote 15 lines
30.06.2010 16:18, ?ilvinas Ledas wrote: > Yes, thanks, I understand that. I just was HOPING it will do what I want > :) I have some kind of "virtual keyboard" but it is only for my own app > (it does send "keys" to 3 TEdit's), so I was hoping such PostMessage() > will work as I expect. As it is not - I will manage to go without it. During the last year I already heard 3 times about virtual keyboards in Lazarus applications. All the 3 times developers are trying to emulate the real keyboard event. There is no cross-platform way to do this in Lazarus. I know some devels found the way to emulate keyboard events in linux but personaly I would probably choose to manage the controls content in the program instead if there are not too much different control types.

Ok, thanks for info.
I solved (at least partly now) this issue just as you proposed - I am manupulating content directly.

Thanks for your opinion
?ilvinas