Tuesday, 1 April 2014

event callback does not get executed in tradition gtk3 widget

Currently perplexing to emanate a tradition widget that is formed directly
on GtkWidget, outlines it as drawable and draws calm with cairo. So many
for a context.As shortly as we try to hoop events (so we can exercise
zoom) - generally a confine eventuality - only does not work and we am not
certain as of why.The callback does get executed on focus-in/focus out
(good aged imitation matter proves that), though we do never ever get any
confine circle activity detected by that callback (button clicks are
pivotal press/release do not work either).I attempted to offshoot adult to
a eventuality fasten byusing a duty pointer and assigning callback duty
(which we cruise is a right thing to do)using g_signal_connect (mywidget,
"event",..) from foo_new or foo_initNeither did work.The Foo init:foo_init
(Foo *self){ GtkWidget *widget = GTK_WIDGET (self);
gtk_widget_set_has_window (widget, FALSE); self->priv = FOO_GET_PRIVATE
(self); gtk_widget_add_events (widget, GDK_ALL_EVENTS_MASK);
g_assert ((gtk_widget_get_events (widget) & GDK_SCROLL_MASK) != 0); //just
glorious /* total some things we also attempted though did not work */
gtk_widget_set_sensitive (widget, TRUE); gtk_widget_set_can_focus
(widget, TRUE); gtk_widget_grab_focus (widget); ...How can we get
all a events of my widget?Assigning widget_class->key_press_event =
my_handler_callback; indeed works as approaching and we get a keys we
press, though a unequivocally same widget_class->button_press_event =
my_handler_callback; or widget_class->scroll_event = my_handler_callback;
assignments do not work!widget_class->key_press_event =
my_handler_callback; // workswidget_class->key_release_event =
my_handler_callback; // workswidget_class->button_press_event =
my_handler_callback; // NOTwidget_class->button_release_event =
my_handler_callback; // NOTwidget_class->scroll_event =
my_handler_callback; // NOTThis finished me suspicious. To accept this
signal, a GdkWindow compared to a widget needs to assent a
GDK_BUTTON_PRESS_MASK mask.Is it required to comprehend a widget before
gtk_widget_add_events "works"...?Update: Tried to call
gtk_widget_add_events after gtk_widget_show_all. No change.Update:
example#ifndef __FOO_H__#define __FOO_H__#include G_BEGIN_DECLS#define
FOO_TYPE (foo_get_type ())#define FOO(obj)
(G_TYPE_CHECK_INSTANCE_CAST ((obj), FOO_TYPE, Foo))#define FOO_CONST(obj)
(G_TYPE_CHECK_INSTANCE_CAST ((obj), FOO_TYPE, Foo const))#define
FOO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), FOO_TYPE,
FooClass))#define FOO_IS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
FOO_TYPE))#define FOO_IS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
FOO_TYPE))#define FOO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
FOO_TYPE, FooClass))typedef struct _Foo Foo;typedef struct
_FooClass FooClass;typedef struct _FooPrivate FooPrivate;struct _Foo{
GObject parent; FooPrivate *priv;};struct _FooClass{ GObjectClass
parent_class;};GType foo_get_type (void) G_GNUC_CONST;Foo *foo_new
(void);G_END_DECLS

No comments:

Post a Comment