mirror of
https://github.com/kusti8/proton-native.git
synced 2026-05-15 14:15:50 -06:00
[GH-ISSUE #47] Feature: Select Folder type of Dialog #27
Labels
No labels
bug
documentation
enhancement
libui issue
pull-request
question
wait for libui implementation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/proton-native#27
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @armand1m on GitHub (Mar 5, 2018).
Original GitHub issue: https://github.com/kusti8/proton-native/issues/47
Feature Request
Currently, when using the
Dialogmethod, we can use the DialogTypeEnum to determine if we want a dialog for:Well, it turns out that sometimes we want the user to also select a folder instead of a file. So I would like to propose a new DialogType:
User Story
As a user,
I want to be able to select a folder,
In order to select the destiny of a generated file, for example.
As a developer,
I want to be able to popup a Dialog to request a folder destiny to the user,
In order to get the path I should use as destiny of a generated file, for example.
(I'm no good at writing user stories, but well, I tried)
@armand1m commented on GitHub (Mar 5, 2018):
Well, it seems to be necessary a pull request for this in https://github.com/parro-it/libui-node and https://github.com/andlabs/libui :/
I've already take a look at the files needed to implement a new method for this in libui, it would be necessary to modify these files:
darwin:
86c4485578/darwin/stddialogs.mwindows:
86c4485578/windows/stddialogs.cppunix:
86c4485578/unix/stddialogs.cDon't know if there is any other needed, probably I may need to expose this somewhere.
@mischnic commented on GitHub (Mar 6, 2018):
Probably two new types are needed:
OpenFolderandSaveFolder(this would also make it clearer that there are related to theirOpen/Savecounterparts)because on all platforms, you have to select one type (i.e.
NSSavePanelorNSOpenPanel).@mischnic commented on GitHub (Mar 11, 2018):
There was already a pull request for openFolder (closed): https://github.com/andlabs/libui/pull/190
@armand1m commented on GitHub (Mar 12, 2018):
@mischnic nice to know this, maybe I can build a PR up on this, but I didn't found it in the master branch if I can recall (I need to take a look again..). Maybe it was removed later?
EDIT
Sorry, now I see that the PR was rejected. I'll start the discussion again on why this was made.
@andlabs commented on GitHub (Mar 14, 2018):
I didn't reject the PR. I decided to hold off on merging it, because the current APIs for dialogs isn't ideal. It all has to do with event handling and synchronicity. I'll use pseudocode in JavaScript to explain what I mean (this will probably be easier than explaining it in C in the main repo, to be honest...).
On Windows, the system dialog API only gives me one option:
You'll notice this function does not return until the dialog is dismissed. You'll notice that a parent window must be specified. Clicking on that window while the dialog is open will cause that window to flash.
Other windows can still be interacted with, but they will NOT respond to things like tab navigation. This is because tab navigation on Windows is intrinsically tied to dialog boxes! Specifically, the
IsDialogMessage()function requires you to pass a handle to the top-level window (I'm not sure if it's the dialog box or the parent window), and only handles tab navigation for the window you passed in. libui works around this for the outermost main loop by passing the currently active window into this function, but in therunDialog()function above I have no such control. Likewise, I have no such control over what happens inside the main loop body, so no custom main loops (uiMainSteps()/uiMainStep()).I could also disable all the windows during the dialog's lifetime, but then clicking on those other windows won't flash the dialog window (and I don't think I have a way to do this myself at all...).
Now I could theoretically use a dialog message hook to try to work around this, but I'm not sure if this solution might be flaky (I would have to write it). I have tried to deduce what the correct programming model on Windows is based on all this information, even going so far as to ask outright, but I can't get an answer out.
Failure to provide a parent window will cause Windows to not flash the dialog window when clicking other windows.
GTK+ is the nicest of the bunch, as I have two options:
The former will prevent interaction with any window during the dialog's lifetime, but in a weird some-of-the-events-still-go-through way. I also can't do any custom main loops with this option.
The latter will let you interact with everything else in the program while the dialog is running. I don't remember if there were caveats, but notice you still need to provide a window to disable while the dialog is running.
In both cases, failure to provide a parent window will do nothing but cause GTK+ to spit the dreaded
GtkDialog mapped without a transient parenton stderr.macOS is only slightly less nice:
In the former case, the dialog is global to the application, and all window interaction is blocked until the dialog is dismissed. I also can't do any custom main loop stuff.
In the latter case, the dialog is modal to to a specific window, and appears as a "sheet" that pulls down from the titlebar. You can still interact just fine with other windows, under certain circumstances. While custom main loops are still possible, this approach probably tells NSApplication to run in a different main loop run mode which might affect things. I need to read more on how NSApplication and sheets work together before I can make a verdict here. Also, you must provide a parent window in this case.
So hopefully that explains the dilemma.
@mischnic commented on GitHub (Apr 3, 2018):
New issue tracking progress: https://github.com/andlabs/libui/issues/314
@kusti8 commented on GitHub (Jan 19, 2020):
Proton Native V2 is now released! If the issue still occurs in the new update, please open a new issue.