On Mon, 14 May 2007 16:11:11 +0200
Nicolas Cannasse <[EMAIL PROTECTED]> wrote:
> > First, neko is awesome, i'm finding the FFI very intuitive to use.
> > Thanks for such great software.
> >
> > I'm attempting to wrap Gtk in neko for use in haxe and so far it's
> > going quite well, but my first question is
> >
> > value labelSetText(value w,value l) {
> > val_check_kind(w,k_label);
> > val_check(l,string);
> > gtk_label_set_text(GTK_LABEL(val_data(w)),val_string(l));
> > return val_true;
> > }
>
> val_string is a reference, not a copy.
> But I think that gtk_label_set_text itself makes a copy of the
> parameter string, so I think it should be working.
>
> > And I've come across a bizarre problem with the function above, I
> > call it with
>
> Where does your label comes from ? It might be "null", or not
> correctly wrapped using new String(s) after readed from neko.
>
> Nicolas
>
>
Hi Nicholas
I think I found the error I was doing this
entry.connect(Event.activate(function(w) { button.label =
entry.text;} ));
Now, I get it, cos I have to dereference a haxe string
to a neko string and I have to re-wrap the other way too! GReat thanks.
btw, give me a month and haxe won't be a "web oriented" universal
language anymore :)
Gtk is going to be nice in haxe, here's a test prog so far, it works
great.
class Test {
public static function main() {
App.init();
var win = new Window();
var vbox = new VBox(true,2);
win.add(vbox);
var button = new Button();
vbox.add(button);
var entry = new Entry();
vbox.add(entry) ;
var closure:String = "yes i do ";
entry.text = closure ;
button.label = "yipee";
button.connect(Event.clicked(function(w)
{ App.quit(); } ));
var enter_ev =
Event.enter(function(w){neko.Lib.println("Enter");});
var exit_ev =
Event.leave(function(w){neko.Lib.println("Leave");});
button.connect(enter_ev);
button.connect(exit_ev);
win.connect(Event.delete(function(w){ neko.Lib.println("aha");
}));
var lbl = new Label("blah");
vbox.add(lbl);
lbl.show();
var bt2 = new Button() ;
bt2.label = "mmm";
bt2.show();
vbox.add(bt2);
bt2.connect(enter_ev);
bt2.connect(exit_ev);
bt2.connect(Event.clicked(function(w) {
lbl.label= entry.text;
neko.Lib.println(entry.text) ;
} ));
//entry.connect(Event.focus_out(function()
{button.label = entry.text; }));
entry.connect(Event.activate(function(w)
{ button.label = entry.text;} ));
win.show();
vbox.show();
entry.show();
button.show();
App.run();
}
}
--
"It is no measure of health to be well adjusted to a profoundly sick
society." --Jiddu Krishnamurti
--
Neko : One VM to run them all
(http://nekovm.org)