[Lazarus] Gtk3 - Set entry placeholder

Krzysztof dibo20 at wp.pl
Mon Jan 5 20:37:32 CET 2015


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'));
end;

Then it doesn't work. Edit1.Handle should point to gtk widget right?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20150105/2312d7ee/attachment-0002.html>


More information about the Lazarus mailing list