From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: GTK key-press-event Date: Wed, 2 Nov 2016 10:45:21 +0100 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: vZYCW951TbFitc4GdEwQJg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:32219 Date: 2016-11-02T10:45:21+01:00 List-Id: On 02/11/2016 10:19, hreba wrote: > I am trying to write a key press handler with user data. I know how to > connect the handler and that its type is > > type Handler is access procedure > Widget : access Widget_Type'Class; > Params : Glib.Values.GValues; > User_Data : User_Type); There is a typed marshaller for handing this type of events: type Handler is access function ( Widget : access Gtk_Widget_Record'Class; Event : Gdk_Event; User_Data : User_Type ) return Boolean; > What I don't know is how to get the key which was pressed. The event parameter contains input event type and if that was a keyboard event, the key pressed/released: case Get_Event_Type (Event) is when Key_Press => -- This a key-press event case Get_Key_Val (Event) is when GDK_Insert => -- This is INSERT key ... > A few months ago I had a similar problem where I needed a Cairo Graphics > context, and I got it from the parameter list "Params" , selecting the > first component with Glib.Values.Nth(), and converting that with > Cairo.Get_Context. You could use Nth () but there is no reason doing that. And for this type of event there is a return value. Note that key press events must be unmasked to be emitted. Then some widgets never emit these events anyway. They must be wrapped into an "event-box" which itself is invisible but emits the events. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de