On 01/05/2015 08:37 PM, Krzysztof wrote:
Hi,

I'm testing Gtk3 (I know that it is in alpha stage). I have latest
lazarus from svn (1.3)

When using low level Gtk3 api then this code work fine:

uses
   {$IFDEF UNIX}{$IFDEF UseCThreads}
   cthreads,
   {$ENDIF}{$ENDIF}
   Interfaces, // this includes the LCL widgetset
   LazGtk3, LazGObject2;

{$R *.res}

var
   window: PGtkWindow;
   entry1, entry2: PGtkWidget;
   vbox: PGtkWidget;

begin
   gtk_init (@argc, @argv);

   window := gtk_window_new (GTK_WINDOW_TOPLEVEL);
   gtk_window_set_title (window, 'Window');

   g_signal_connect_data(window, 'destroy', TGCallback(@gtk_main_quit),
nil, nil, 0);

   vbox := gtk_box_new(GTK_ORIENTATION_VERTICAL, 2);
   gtk_container_add (PGtkContainer(window), vbox);

   entry1 := gtk_entry_new ();
   gtk_entry_set_text(PGtkEntry(entry1), 'Hello');

   entry2 := gtk_entry_new ();
   gtk_entry_set_placeholder_text(PGtkEntry(entry2), '<Test>');

   gtk_box_pack_start(PGtkBox(vbox), entry1, True, True, 0);
   gtk_box_pack_start(PGtkBox(vbox), entry2, True, True, 0);

   gtk_widget_show_all (window);

   gtk_main ();
end.

But if I create LCL application, then change LCLWidgetType to Gtk3 and
call this:

procedure TForm1.Button1Click(Sender: TObject);
begin
   gtk_entry_set_placeholder_text(Edit1.Handle), PChar('Test'));

That's because Edit1.Handle is not PGtkEntry, but TGtk3Entry, so this code should work (you must include gtk3widgets unit to get it work):
gtk_entry_set_placeholder_text(PGtkEntry(TGtk3Edit(Edit1.Handle).Widget), 
PChar('Test'));
or
var
  AEntry: PGtkEntry;
begin
  AEntry := PGtkEntry(TGtk3Edit(Edit1.Handle).Widget);
  gtk_entry_set_placeholder_text(AEntry, PChar('Test'));
end;

zeljko


--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to