On Wed, Oct 02, 2002 at 05:37:51PM +0200, Philippe Ney wrote:
> Hi Micah,
>
> To send keyboard events to a widget without using the keyboard, I try to
> use the pgInFilterSend function.
>
> I have the following app:
> A text area and a button widgets. And I want to send a keyboard event like
> for example ctrl-x to the text area when the button is pushed.
>
> The problem I have is that I don't know how to set the target widget to
> send the events. I thought that it could be the one focused and then use
> something like:
>
> static pghandle wEdit;
>
> int evtBtn (struct pgEvent *evt)
> {
> static union pg_client_trigger trig;
>
> trig.content.type = PG_TRIGGER_CHAR;
> trig.content.u.kbd.mods |= PGMOD_CTRL;
> trig.content.u.kbd.key = PGKEY_x;
> pgFocus (wEdit);
> pgInFilterSend(&trig);
> }
>
> but the event isn't send to the wEdit widget...
>
> Do you have any tips?
An event generated with pgInFilterSend will be handled exactly like one
recieved from the input drivers. The step of dispatching the event to a
widget is handled by the last input filter in the chain, and currently it's
not possible for a driver or input filter to effect this dispatch process.
So, if your widget responds to CTRL-X from the keyboard when focused, this
should work. I do see two problems with it:
1. You _must_ zero the contents of the trig structure first. The
pg_client_trigger structure has many members you don't care about, and
the default value is 0. Just add a line like
memset(&trig,0,sizeof(trig));
2. You probably don't want a PG_TRIGGER_CHAR event. That's for characters
that have been translated to ASCII/Unicode, not for control keys,
hotkeys, shortcuts, and such that don't have any textual representation.
Try a PG_TRIGGER_KEY event instead. This will be converted to a pair of
KEYUP/KEYDOWN triggers in the if_key_preprocess input filter.
>
> TIA,
> -philippe
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Pgui-devel mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/pgui-devel
--
Only you can prevent creeping featurism!
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Pgui-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/pgui-devel