andlabs / libui

Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.
Other
10.73k stars 616 forks source link

Proposal: submit for uiForm #189

Open emersion opened 8 years ago

emersion commented 8 years ago

Right now pressing the Enter key when typing in a uiForm does nothing. It should submit the form.

One solution would be to add a uiFormOnSubmitted function that calls the callback when Enter is pressed in the form's uiEntry childs. A uiFormSubmit function can be added to submit the form when clicking a button.

Thoughts?

andlabs commented 8 years ago

uiForm does not have a concept of submitting, because it is purely a layout container.

What you are describing would be done with the "default button" of a dialog. When I add custom dialogs, you will be able to do exactly this, and with any layout container.

PaulBGD commented 8 years ago

Custom dialogs sound awesome! You see them a lot in GTK and macOS. Do you have any sort of ETA on those?

andlabs commented 8 years ago

No, because dialogs are held up by OSs being highly incompatibly different with issues of modality. I don't know how to solve it, and explaining it will be more complex than explaining the menu issue.

bcampbell commented 6 years ago

I'm looking at some tangentially dialog-related issues at the moment, so I'll add my notes here for future reference:

On Gtk, there's GtkDialog:

Seems quite nice and simple, and easy to understand. At first glance, anyway ;-) If libui could have a model along these lines I'd be pretty happy, but need to see what windows and osx do.

bcampbell commented 6 years ago

I think the NSPanel window subclass is the OSX equivalent:

bcampbell commented 6 years ago

Windows Dialog Box reference

bcampbell commented 6 years ago

Looks like on windows you can, in fact, subclass the Dialog Box and create the layout yourself without faffing about with a dialog template.

andlabs commented 6 years ago

GTK+: you do not have to follow the standard widget layout for dialog boxes. You don't even have to use GtkDialog as GtkWindow already has all the relevant properties in it, but I forget if there are any edge cases that make this not-ideal.

Windows: you do not have to use the dialog template system at all. In fact, you don't even have to use WC_DIALOG; Raymond Chen has a series of articles in which you recreate the functionality of the DialogBox() function!

The platform-incompatible issues I mentioned are much more subtle than anything you listed here. I can talk about them in more detail later.