Thread overview
GUI text input dialog with few lines
Oct 20, 2023
Felipe Lema
Oct 20, 2023
Adam D Ruppe
Oct 20, 2023
Felipe Lema
Oct 23, 2023
Felipe Lema
Oct 23, 2023
Felipe Lema
Oct 28, 2023
Adam D Ruppe
October 20, 2023

Hey, D-langers

Is there a mostly-one-liner for getting text input (actually TOTP numbers) from user?

I'm looking into something like Qt's QInputDialog::getText() in which it returns a string and all things gui are handlend underneath (see code sample here: https://doc.qt.io/qt-6/qinputdialog.html#details)

I was looking into DWT and dlangui without luck. Maybe they both have it, but it's called something else (TextFromUser, UserDialog...)?

I don't mind using any or other GUI framework, but I do aim to have a windows-exe-with-as-few-dlls-as-possible

Thanks y'all

October 20, 2023

On Friday, 20 October 2023 at 20:43:21 UTC, Felipe Lema wrote:

>

I don't mind using any or other GUI framework, but I do aim to have a windows-exe-with-as-few-dlls-as-possible

My minigui.d can do this fairly easily:

import arsd.minigui;

void main() {
        // need to define the data you want in a struct,
        // it requires a struct even if you only want one item
        struct Data {
                string code;
        }

        // then do the dialog function with the struct and it
        // auto-creates a dialog for all the parts of the struct
        // and calls the function you provide when the user hits OK
        dialog((Data received) {
                // you got the number here
                messageBox("You gave me " ~ received.code);

                // note that if they hit cancel, this function is NOT
                // called, the dialog is just closed without running
                // this code.
        });

        // need to run the event loop explicitly, this will return when
        // all windows are closed
        EventLoop.get.run();
}

If you use dub you can add it as dependency:

https://code.dlang.org/packages/arsd-official%3Aminigui

arsd-official:minigui

If you don't use dub, it needs about 6 files out of the repo, but i suggest you clone the whole thing then use dmd -i.

But anyway, on Windows it uses the native text box so there's no dlls needed. On Linux, it uses my full custom stuff so no libs required there either.

October 20, 2023

On Friday, 20 October 2023 at 21:03:53 UTC, Adam D Ruppe wrote:

>

On Friday, 20 October 2023 at 20:43:21 UTC, Felipe Lema wrote:

>

[...]

My minigui.d can do this fairly easily:

import arsd.minigui;

[...]

O-M-D !

This is exactly what I needed. Many thanks

October 23, 2023

On Friday, 20 October 2023 at 21:19:40 UTC, Felipe Lema wrote:

>

On Friday, 20 October 2023 at 21:03:53 UTC, Adam D Ruppe wrote:

>

On Friday, 20 October 2023 at 20:43:21 UTC, Felipe Lema wrote:

>

[...]

My minigui.d can do this fairly easily:

import arsd.minigui;

[...]

O-M-D !

This is exactly what I needed. Many thanks

Hey, I know this is stretching it out, but ... how can I do "Ctrl-v" to paste the clipboard content? (I'm mostly interested in windows, but any "handle ctrl-v with this code block" using pbpaste or xclip will do)

October 23, 2023

On Monday, 23 October 2023 at 16:50:08 UTC, Felipe Lema wrote:

>

On Friday, 20 October 2023 at 21:19:40 UTC, Felipe Lema wrote:

>

On Friday, 20 October 2023 at 21:03:53 UTC, Adam D Ruppe wrote:

>

On Friday, 20 October 2023 at 20:43:21 UTC, Felipe Lema wrote:

>

[...]

My minigui.d can do this fairly easily:

import arsd.minigui;

[...]

O-M-D !

This is exactly what I needed. Many thanks

Hey, I know this is stretching it out, but ... how can I do "Ctrl-v" to paste the clipboard content? (I'm mostly interested in windows, but any "handle ctrl-v with this code block" using pbpaste or xclip will do)

note: ctrl-v is working in windows automagically, but not in linux... can I do something like handle("CTRL","v", ...) ?

October 28, 2023

On Monday, 23 October 2023 at 16:50:08 UTC, Felipe Lema wrote:

>

Hey, I know this is stretching it out, but ... how can I do "Ctrl-v" to paste the clipboard content?

Ah, sorry, I missed this - I don't follow this forum daily (it was pure coincidence your first message came in when I happened to be looking at it, feel free to CC my destructionator@gmail.com email if you need a quicker answer).

For text input, ctrl+v should just work automatically, it is handled by the widget itself. Can you check the version you have? On linux my thing was annoyingly buggy (like it'd usually work but not always) until i think version 11.1.

If we had to though you can add a addEventListener key press thing but it should just work...