PDA

View Full Version : Modal popups?



Varsuuk
September 9th, 2019, 05:18
I saw some of my code duplicated, what I thought was sloppy until after I moved it I saw odd behavior.

I realized it was because I had the same cleanup code duplicated at the end the "handler" method for attemptToMultiClass and attemptToDualClass methods instead of where I would logically put it after it checks if first class, multi or dual then falls through to the cleanup.

This does not work because I call "Interface.openwindow()" to present the user with a "are you sure" option (but it may be more than that in future, so don't assume a yes/no is sufficient for the popup) and the code falls through to the cleanup before the new window is closed and therefore the settings made in the window haven't yet been made.

I got around this by making sure I did nothing after the openWindow calls and handled all "post window" code in the window handlers. No problems. Just wondered if I missed a way to call a window "modally" where it interrupts all until you clicked a choice and returns to caller?

celestian
September 9th, 2019, 14:07
The only thing im aware of that is remotely like that is this.

https://www.fantasygrounds.com/refdoc/Interface.xcp#dialogMessage

I've tried it but decided against it because it's pretty crude.

Bidmaron
September 10th, 2019, 04:16
And it jars you right out of the suspension of disbelief with a very harsh and sparse windowy dialog box. It blows super big chunks. Not that I have any feelings about the subject....

Trenloe
September 10th, 2019, 05:07
And then if the user doesn't click it for a while their instance of FG lags way behind in processing messages/code etc. and you're a bit screwed.

Bidmaron
September 10th, 2019, 05:13
Just happy bitching, Trenloe.

Without multi-threading, a modal window is, as you point out, a real problem.

Varsuuk
September 10th, 2019, 07:03
The only thing im aware of that is remotely like that is this.

https://www.fantasygrounds.com/refdoc/Interface.xcp#dialogMessage

I've tried it but decided against it because it's pretty crude.


Yeah, that yes/no/cancel option was only one I saw.

Like said, I made due by copying the 4 calls I needed at end to each of the 3 possible paths since 2 of them required input from the user. Works fine enough, just wanted to make sure I didn’t miss another paradigm.

Varsuuk
September 10th, 2019, 07:06
And then if the user doesn't click it for a while their instance of FG lags way behind in processing messages/code etc. and you're a bit screwed.

Yeah, in my worlds, the method that calls this pop up would be suspended until the pop up returned but due to the magic of threading and synchronization background processing and message handling could go on.

But I get what you mean, it’s one reason I moved the code into the window handler instead.