buggins / dlangui

Cross Platform GUI for D programming language
Boost Software License 1.0
816 stars 122 forks source link

TextWidget.click is not firing #686

Open whitebyte opened 1 month ago

whitebyte commented 1 month ago
import std.stdio : writeln;
import dlangui;

mixin APP_ENTRY_POINT;

extern (C) int UIAppMain(string[] args) {
    Window window = Platform.instance.createWindow("", null);

    auto w = new TextWidget();
    w.text = "Test 123";
    w.click = delegate(Widget w) {
        writeln(w.text);
        return true;
    };

    window.mainWidget = w;
    window.show();

    return Platform.instance.enterMessageLoop();
}

When I run this example and click the widget, nothing happens. If we replace TextWidget with Button it works as intended. I'm looking here http://buggins.github.io/dlangui/ddox/dlangui/widgets/controls/TextWidget.html and I have an impression that TextWidget should be clickable. Am I missing something here?

whitebyte commented 1 month ago

Also for some reason TextWidget won't appear until the main window resize, but I guess it's a separate issue

GrimMaple commented 1 month ago

If we replace TextWidget with Button it works as intended. I'm looking here http://buggins.github.io/dlangui/ddox/dlangui/widgets/controls/TextWidget.html and I have an impression that TextWidget should be clickable. Am I missing something here?

Hi! I've looked into the source code, and clicking is actually disabled for TextWidget. Actually-actually, clicking has to be explicitly enabled for a widget, which TextWidget doesn't do, so it never gets to processing clicks. I don't know if it's a bug or intended behavior, and I don't know if clicking a TextWidget should be allowed :)

Also for some reason TextWidget won't appear until the main window resize, but I guess it's a separate issue

I have tested this on Windows 11 and it works fine - TextWidget is displayed as intended. Can you tell me what OS do you use and what platform (x11, SDL, etc)?

whitebyte commented 1 month ago

Indeed, setting clickable = true did the trick.

I don't know if clicking a TextWidget should be allowed :)

I see no reason why not?

Can you tell me what OS do you use and what platform (x11, SDL, etc)?

It's Linux. I guess it's SDL

drug007 commented 1 month ago

In either way - If clicking a TextWidget is not allowed then click property should not be available too.