/src/wrappers/gtk/library/key_event_callback.e
Specman e | 71 lines | 54 code | 13 blank | 4 comment | 3 complexity | 78a28c485ada2757643521bd98cae493 MD5 | raw file
1indexing 2 description: "Generic callback for the key-release-event and key-pressed-event signals" 3 copyright: "[ 4 Copyright (C) 2006 Paolo redaelli, eiffel-libraries team, GTK+ team and others 5 6 This library is free software; you can redistribute it and/or 7 modify it under the terms of the GNU Lesser General Public License 8 as published by the Free Software Foundation; either version 2.1 of 9 the License, or (at your option) any later version. 10 11 This library is distributed in the hope that it will be useful, but 12 WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 Lesser General Public License for more details. 15 16 You should have received a copy of the GNU Lesser General Public 17 License along with this library; if not, write to the Free Software 18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 02110-1301 USA 20 ]" 21 license: "LGPL v2 or later" 22 date: "$Date:$" 23 revision "$Revision:$" 24 25deferred class KEY_EVENT_CALLBACK 26 -- You want to use one of KEY_EVENT_RELEASE_CALLBACK or KEY_EVENT_PRESS_CALLBACK 27 28inherit CALLBACK redefine object end 29 30insert G_OBJECT_FACTORY [GTK_WIDGET] 31 32feature 33 object: GTK_WIDGET 34 35feature 36 37 callback (event_key_ptr: POINTER; instance: POINTER): INTEGER is 38 local 39 key_event: GDK_EVENT_KEY 40 specific_event: GDK_EVENT_ANY 41 do 42 debug print ("Callback: instance=") print (instance.to_string) print ("%N") end 43 -- The following is written with the implicit requirement 44 -- that object actually has an Eiffel wrapper 45 object := wrapper(instance) 46 create key_event.from_external_pointer (event_key_ptr) 47 Result := function.item ([key_event, object]).to_integer 48 -- GTK is about to release this event, detach it from Eiffel 49 key_event.dispose 50 end 51 52 callback_pointer: POINTER is 53 do 54 Result := get_callback_pointer ($callback) 55 ensure 56 Result.is_not_null 57 end 58 59 connect (an_object: GTK_WIDGET; a_function: FUNCTION [ANY, TUPLE [GDK_EVENT_KEY, GTK_WIDGET], BOOLEAN]) is 60 do 61 handler_id := g_signal_connect_closure (an_object.handle, 62 signal_name.to_external, 63 handle, 64 0 -- i.e. call it before default handler 65 ) 66 function := a_function 67 end 68 69 function: FUNCTION [ANY, TUPLE [GDK_EVENT_KEY, GTK_WIDGET], BOOLEAN] 70 71end -- class KEY_EVENT_CALLBACK