Unable to get editable events (Free Pascal) (fwd)



---------- Forwarded message ----------
Date: Fri, 19 Jan 2001 12:24:23 +0200 (SAST)
From: Heinrich du Toit <heinrich localhost>
To: gtk-list localhost
Subject: Unable to get editable events (Free Pascal)

Hi all

I am trying to write an editable widget using free Pascal.
Everything works fine:
But for some reason I never get the events from the editable widget.
Can someone please give me some tips one how to write a widget using 
the editable widget as a base.

I included here 2 procedures I think maybe the problem

procedure edit_realize(widget:Pgtkwidget);cdecl;
var
 attr:tGDKwindowattr;
 mask:guint;
 ed:Pedit;
begin
 gtk_widget_set_flags(widget,GTK_realized);
 ed := Pedit(widget);
 attr.x := widget^.allocation.x;
 attr.y := widget^.allocation.y;
 attr.wclass := gdk_input_output;
 attr.width := ed^.width;
 attr.height := ed^.height;
 attr.event_mask := gtk_widget_get_events(widget) or gdk_exposure_mask
                    or gdk_button_press_mask or gdk_key_press_mask
                    or gdk_key_release_mask
		    or gdk_enter_notify_mask;
{ attr.event_mask := gdk_all_events_mask;}
 attr.window_type := gdk_window_child;
 attr.visual := gtk_widget_get_visual(widget);
 attr.colormap := gtk_widget_get_colormap(widget);
 mask := GDK_WA_X or GDK_WA_Y or GDK_WA_VISUAL or gdk_wa_colormap;
 widget^.window := gdk_window_new(widget^.parent^.window,@attr,mask);
 widget^.thestyle := gtk_style_attach (widget^.thestyle,widget^.window);
 gdk_window_set_user_data(widget^.window,widget);

gtk_style_set_background(widget^.thestyle,widget^.window,GTK_STATE_ACTIVE);

{I think this caused problems!}
{ gdk_window_move_resize(widget^.window,

widget^.allocation.x,widget^.allocation.y,widget^.allocation.width,widget^.allocation.height);}
end;


procedure edit_class_init(theclass:peditclass);cdecl;
var
 object_class :pgtkobjectclass;
 widget_class :pgtkwidgetclass;
 editable_class:pgtkeditableclass;
begin
 object_class := gtk_object_class(theclass);
 widget_class := gtk_widget_class(theclass);
 editable_class := gtk_editable_class(theclass);

 theclass^.parent_class := pgtkeditableclass(gtk_type_class
(gtk_editable_get_type()))^;
 widget_class^.realize := @edit_realize;
 widget_class^.expose_event := @edit_expose;
 widget_class^.size_request := @edit_size_request;
 widget_class^.size_allocate := @edit_size_allocate;
{ widget_class^.key_press_event := @edit_key_press_event;}
 widget_class^.button_press_event := @edit_button_press_event;

 editable_class^.insert_text := @edit_insert_text;
 editable_class^.activate := @edit_activate;
 editable_class^.changed := @edit_activate;
end;



Thanks
Heinrich






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