Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

[MBS] NSSavePanelMBS beginSheetForDirectory modal equivalent? (MBS Xojo Plugin Mailinglist archive)

Back to the thread list
Previous thread: [MBS] WindowsPrintersMBS Problem
Next thread: [MBS] AskSaveChangesDialog as a sheet?


[MBS] CURL MissingFUnctionExcpetion   -   Garth Hjelte
  [MBS] NSSavePanelMBS beginSheetForDirectory modal equivalent?   -   Arnaud Nicolet
   Re: [MBS] NSSavePanelMBS beginSheetForDirectory modal equivalent?   -   Arnaud Nicolet
   Re: [MBS] NSSavePanelMBS beginSheetForDirectory modal equivalent?   -   Arnaud Nicolet
   Re: [MBS] NSSavePanelMBS beginSheetForDirectory modal equivalent?   -   Tim Jones
   Re: [MBS] NSSavePanelMBS beginSheetForDirectory modal equivalent?   -   Arnaud Nicolet
   Re: [MBS] NSSavePanelMBS beginSheetForDirectory modal equivalent?   -   Christian Schmitz

[MBS] NSSavePanelMBS beginSheetForDirectory modal equivalent?
Date: 22.01.12 00:38 (Sun, 22 Jan 2012 00:38:14 +0100)
From: Arnaud Nicolet
Greetings!

The current use of beginSheetForDirectory is to show the dialog and continue the code (i.e. it's not modal). For implementing a Save method, it makes things hard to code (we need to “suspend” the current method (could be FileSave or CancelClose), wait for the dialog to close, and continue the method (that is. trigger the called method again (FileSave or CancelClose (by closing the window again, or quitting the app), but this time by passing the chosen file).

A ShowModalSheetForDirectory method would be the missing method here, simply because a NSSavePanel is meant to suspend the current method. Or is there a workaround?
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] NSSavePanelMBS beginSheetForDirectory modal equivalent?
Date: 23.01.12 17:34 (Mon, 23 Jan 2012 17:34:48 +0100)
From: Arnaud Nicolet
Le 22 janv. 2012 à 11:08 Matin, Christian Schmitz a écrit:

> Maybe simply do a loop and wait?
>
> do
> delayMBS 0.1
> loop until done
>
> or something like that.

Le 22 janv. 2012 à 20:46 Soir, Tim Jones a écrit:

> Since I use the quite regularly in a "do this function and wait" situations, I'll restate that I've found App.DoEvents() in this exact situation is quite safe and very useful.

Indeed, this was the right approach. Thanks Christian and Tim!
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] NSSavePanelMBS beginSheetForDirectory modal equivalent?
Date: 23.01.12 10:13 (Mon, 23 Jan 2012 10:13:41 +0100)
From: Arnaud Nicolet
Le 22 janv. 2012 à 20:46 Soir, Tim Jones a écrit:

> On Jan 22, 2012, at 3:28 AM, Arnaud Nicolet wrote:
>
>> Le 22 janv. 2012 à 11:08 Matin, Christian Schmitz a écrit:
>>
>>>> A ShowModalSheetForDirectory method would be the missing method here, simply because a NSSavePanel is meant to suspend the current method. Or is there a workaround?
>>>
>>> Maybe simply do a loop and wait?
>>>
>>> do
>>> delayMBS 0.1
>>> loop until done
>>>
>>> or something like that.
>>
>> I've considered various ways for that. In the example above, I'd have to use App.DoEvents to not block the UI (no problem for me, but some say it's to be avoided).
>
> Hi Arnaud -
>
> Since I use the quite regularly in a "do this function and wait" situations, I'll restate that I've found App.DoEvents() in this exact situation is quite safe and very useful.
>
> Cliches are sometimes valid - in this case, "the proof is in the tasting of the pudding" and my pudding (using App.DoEvents() ) works very well in 13 different apps and tools on all 3 supported platforms.

Hello Tim!

Thanks for your input. As you, I have used DoEvents with no problem (the "no problem for me" I was referring in my previous message). I'm glad someone confirms me I was right.
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] NSSavePanelMBS beginSheetForDirectory modal equivalent?
Date: 22.01.12 20:46 (Sun, 22 Jan 2012 12:46:36 -0700)
From: Tim Jones
On Jan 22, 2012, at 3:28 AM, Arnaud Nicolet wrote:

> Le 22 janv. 2012 à 11:08 Matin, Christian Schmitz a écrit:
>
>>> A ShowModalSheetForDirectory method would be the missing method here, simply because a NSSavePanel is meant to suspend the current method. Or is there a workaround?
>>
>> Maybe simply do a loop and wait?
>>
>> do
>> delayMBS 0.1
>> loop until done
>>
>> or something like that.
>
> I've considered various ways for that. In the example above, I'd have to use App.DoEvents to not block the UI (no problem for me, but some say it's to be avoided).

Hi Arnaud -

Since I use the quite regularly in a "do this function and wait" situations, I'll restate that I've found App.DoEvents() in this exact situation is quite safe and very useful.

Cliches are sometimes valid - in this case, "the proof is in the tasting of the pudding" and my pudding (using App.DoEvents() ) works very well in 13 different apps and tools on all 3 supported platforms.

Tim

_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] NSSavePanelMBS beginSheetForDirectory modal equivalent?
Date: 22.01.12 11:28 (Sun, 22 Jan 2012 11:28:17 +0100)
From: Arnaud Nicolet
Le 22 janv. 2012 à 11:08 Matin, Christian Schmitz a écrit:

>> A ShowModalSheetForDirectory method would be the missing method here, simply because a NSSavePanel is meant to suspend the current method. Or is there a workaround?
>
> Maybe simply do a loop and wait?
>
> do
> delayMBS 0.1
> loop until done
>
> or something like that.

I've considered various ways for that. In the example above, I'd have to use App.DoEvents to not block the UI (no problem for me, but some say it's to be avoided).
Another consideration is to invoke my various methods in a thread, so I could suspend the thread. Here, I have a problem when the save is started by a CancelClose event (I have to remember the AppQuitting parameter and either close the window again or quit the app (again). Whichever is ugly).

> As you see in Apple's documentation for NSSavePanel class, we use this method:
>
> beginSheetForDirectory:file:modalForWindow:modalDelegate:didEndSelector:contextInfo:

So the behaviour (of not having a modal variant) is because Apple doesn't provide it, I'm right?
(because it seems odd to me they have a modal behaviour for non-sheet variants, then)

Thanks!
_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
<email address removed>
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Re: [MBS] NSSavePanelMBS beginSheetForDirectory modal equivalent?
Date: 22.01.12 11:08 (Sun, 22 Jan 2012 11:08:54 +0100)
From: Christian Schmitz

Am 22.01.2012 um 00:38 schrieb Arnaud Nicolet:

> Greetings!
>
> The current use of beginSheetForDirectory is to show the dialog and continue the code (i.e. it's not modal). For implementing a Save method, it makes things hard to code (we need to “suspend” the current method (could be FileSave or CancelClose), wait for the dialog to close, and continue the method (that is. trigger the called method again (FileSave or CancelClose (by closing the window again, or quitting the app), but this time by passing the chosen file).

As you see in Apple's documentation for NSSavePanel class, we use this method:

beginSheetForDirectory:file:modalForWindow:modalDelegate:didEndSelector:contextInfo:

and there

> A ShowModalSheetForDirectory method would be the missing method here, simply because a NSSavePanel is meant to suspend the current method. Or is there a workaround?

Maybe simply do a loop and wait?

do
delayMBS 0.1
loop until done

or something like that.

Greetings
Christian