Re: [gtkmm] emiting key release signals



The reason I want to do this: I have some custom hardware with keys on
them (including a number pad and some non keyboard) and I'm trying to
figure out how to programmically emit key press/release signals. I'm not
spoofing events, I need to trigger them for actual key press/releases
that are just coming from a source other than the keyboard.

If I were to instead call the code triggered by on_key_release_event I
would have to go through the pain of manually figuring out who has the
focus and if they need to get these keys. And since some of these keys
are number keys like on the keyboard I would have to do the same thing
for normal widgets too. No, its much simpler just to tie my custom keys
into the program's normal event handling. If I can do that then
everything else will just work as normal.



On Sat, 2003-08-16 at 11:33, Chris Vine wrote:
> On Friday 15 August 2003 10:12 pm, Peter Gasper wrote:
> > No ideas?
> >
> > On Wed, 2003-08-13 at 16:06, Peter Gasper wrote:
> > > How can I emit a key_release signal?
> > >
> > > I tried using gtk_main_do_event() as instructed in the docs for
> > > Gtk::Wiget::event() but that didn't work. I don't know if I was doing it
> > > right, but I also don't know if that is the correct way in the first
> > > place. If this is the correct method, let me know and I'll post the code
> > > that doesn't work.
> > >
> > >
> > > background: I have some custom hardware with keys on them (including a
> > > number pad) and I'm trying to figure out how to programmically emit key
> > > press/release signals.
> > >
> > > thanks.
> 
> The Gtk+ reference material on gtk_main_do_event() is somewhat delphic (it 
> advises that the function should not generally be used).
> 
> Having said that, the usual standard reply to those who want to synthesize 
> events directly is, I am afraid, why are you trying to do this?  If it is to 
> cause the hardware to think that a key has been released, Gtk+ won't do this 
> for you (as far as I am aware), nor I suspect will any other other X based 
> GUI toolkit.  If on the other hand you want the program to behave as if a key 
> had been released, why not call the code which would otherwise be executed by 
> Gtk::Widget::on_key_release_event(), either directly or by connecting a 
> custom signal to the event handler?
> 
> I personally have never come across any circumstances in which I have had to 
> try to spoof the main event loop into thinking that an event has occurred, 
> and the absence of a response to your question probably indicates that others 
> haven't either.  I do not say there are no circumstances in which that may 
> not be a sensible coding solution to a particular problem, but your short 
> explanation does not indicate why you need to do it.
> 
> If you want to follow up the use of gtk_main_do_event() further, probably it 
> would be best to do so on the Gtk+ mailing list.
> 
> Chris.
> 
-- 
Peter Gasper <pgasper designadvantage com>




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]