haxeui / hxWidgets

Haxe externs (and wrappers) for wxWidgets
MIT License
77 stars 22 forks source link

[Linux] getValue() trace on TextCtrl traces something completely different #25

Closed tienery closed 8 years ago

tienery commented 8 years ago

I went ahead to implement the getValue() and setValue() methods in the TextCtrl as without them the control is kind of useless on its own. But testing it, I'm getting unusual results on Linux, and I was wondering if you can reproduce these results and find out what's causing it.

Using the following code:

    var app = new App();
    app.init();

    var mainFrame = new Frame(null, "Test");
    mainFrame.setSize(800, 600);
    mainFrame.show(true);

    var mainPanel = new Panel(mainFrame);
    mainPanel.setSize(800, 600);

    var mainTextBox = new TextCtrl(mainPanel, TextCtrlStyle.MULTILINE);
    mainTextBox.move(3, 3);
    //mainTextBox.setSize(750, 140);
    mainTextBox.setClientSize(750, 300);
    mainTextBox.bind(EventType.TEXT, function(e)
    {
        trace(mainTextBox.getValue());
    });

I get the following trace output:

img

ianharrigan commented 8 years ago

what happens if you set the value first?

tienery commented 8 years ago

Setting it using an additional line of code: mainTextBox.setValue(""); doesn't seem to make much difference.

ianharrigan commented 8 years ago

btw... there is already a value prop

ianharrigan commented 8 years ago

actually, thats not true... ignore me...

tienery commented 8 years ago

I will try to use the label field see if that makes any difference.

Update: Okay, that didn't make much difference other than different symbols. Problem with Linux perhaps?

ibilon commented 8 years ago

getValue returns a wxString not a std::string that could be the cause of the problem.

ianharrigan commented 8 years ago

i just implemented .value as:

@:native("SetValue")            public function setValue(value:ConstCharStar):Void;
@:native("GetValue")            public function getValue():ConstCharStar;

and tried:

var textctrl:TextCtrl = new TextCtrl(frame, null, TextCtrlStyle.MULTILINE | TextCtrlStyle.RICH);
textctrl.appendText("This is line 1\n");
textctrl.appendText("This is line 2\n");
textctrl.appendText("This is line 3\n");
textctrl.appendText("This is line 4\n");
textctrl.appendText("This is line 5\n");
trace("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX " + textctrl.value);

And it seemed to work fine... ie, trace was correct (on windows)

tienery commented 8 years ago

Have you tried it with the event binding? That's where it goes wrong for me.

ianharrigan commented 8 years ago

image

This is windows though

tienery commented 8 years ago

Yeah, on Linux I'm having different results with your code as well... I'm getting this:

img

That is the full results, by the way, I'm not joking.

ianharrigan commented 8 years ago

this is kinda strange though:

            var label:StaticText = new StaticText(box, "Static text");
            label.label = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
            trace(">>>>>>>>>> " + label.label);

image

tienery commented 8 years ago

Is that on Linux?

ianharrigan commented 8 years ago

nope - its something to do with the length.

TEST

is fine,

TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST

isnt.

Im guessing as @ibilon said, its something to do with a wxString conversion.

ianharrigan commented 8 years ago

So this will be fixed soon(ish). Im currently reworking the externs with @ibilon to make the externs (and the wrappers) better, and part of that is to use wxStrings properly when appropriate. Theres a lot to get through but it'll get done eventually - you can follow progress here: https://github.com/ianharrigan/hxWidgets/tree/feature/haxe-3.3

ianharrigan commented 8 years ago

Can you try that now from master - the branch has now been merged and the externs correctly use wxString which seems to overcome any issues i had with large strings, im guessing it will have a similar effect to you.

tienery commented 8 years ago

Okay, I'll try it later when I get the chance.

mrcdk commented 8 years ago

This seems to be fixed http://i.imgur.com/fDfwp3N.png

Ubuntu 16.04 using latest master and dev Haxe and hxcpp

ianharrigan commented 8 years ago

Cool, yeah, pretty sure all the string issues are fixed now since we are using wxString. Ill close this and if any more issues pop up we can deal with them as and when.

Cheers.