They certainly could use the same if the both call through to the same method 
you implement. 
Depends on app design perhaps. 

Sent from my iPhone

> On 2015/03/17, at 20:00, Jonathan Taylor <jonathan.tay...@glasgow.ac.uk> 
> wrote:
> 
>> On 17 Mar 2015, at 10:53, <dangerwillrobinsondan...@gmail.com> wrote:
>> Also see the sample code. 
>> It's a lot easier to see how the API is expected to be used. 
>> The docs are a little thin in their descriptions. 
>> 
>> https://developer.apple.com/library/mac/samplecode/ObjectPath/Introduction/Intro.html
> 
> Thanks very much for pointing me to that, that's interesting. However, it 
> does rather emphasize my point about consistency between programatically 
> bringing up the Open dialog and doing it through the path control. In that 
> demo code, if you set the control type to 'popup' then:
> - Clicking on "set path" brings up an open panel on the window, that has been 
> customized with the word "Choose", etc
> - Clicking on the path popup and selecting "Choose" brings up an open dialog 
> that has been customized using a separate chunk of duplicated code.
> 
>> Well the sample code illustrates that the delegate method should be the 
>> place to configure the open panel.
> 
> As I say, there are two separate places in the code where the configuring 
> takes place, to handle these two different ways of setting the path. I just 
> feel it would be nice if "set path" could trigger the same code as going 
> through the path popup. The fact that Apple's own sample code doesn't do this 
> is certainly a good hint that it probably isn't meant to be possible, though!
> 
> 
>>> On 2015/03/17, at 19:36, dangerwillrobinsondan...@gmail.com wrote:
>>> 
>>> Have you tried just displaying an NSOpenPanel yourself then setting the 
>>> selected URL returned to the path control's URL property?
>>> 
>>> Sent from my iPhone
>>> 
>>>> On 2015/03/17, at 19:16, Jonathan Taylor <jonathan.tay...@glasgow.ac.uk> 
>>>> wrote:
>>>> 
>>>> OK, I've got part of the way to a solution, but haven't got it fully 
>>>> working yet. Perhaps the weekday crowd here can advise?
>>>> 
>>>> I've realised that I can get my path control to performClick:
>>>> 
>>>> // When adding a new sequence we immediately prompt the user to select a 
>>>> folder to use for image files
>>>> simulatingPathControlClick = true;
>>>> [folderSelectPopup performClick:self];
>>>> simulatingPathControlClick = false;
>>>> 
>>>> This is a good start, because I see my delegate function being called:
>>>> 
>>>> -(void)pathControl:(NSPathControl*)pathControl willPopUpMenu:(NSMenu*)menu
>>>> {
>>>> if (simulatingPathControlClick)
>>>> {
>>>>     [menu performActionForItemAtIndex:0];
>>>> }
>>>> }
>>>> 
>>>> This seems to be the only way of getting access to the menu 
>>>> (folderSelectPopup.menu always seems to return nil...). Now that I have 
>>>> access to the menu I can get it to performActionForItemAtIndex. That is 
>>>> basically what I'm trying to do here. However it doesn't quite work as it 
>>>> should. The code as written here brings up the Open dialog, which works as 
>>>> intended, but I am calling it sooner than I should (in willPopUpMenu; the 
>>>> menu has not yet popped up!). As a result, after the user dismisses the 
>>>> Open dialog, THEN the "choose" menu on the path control pops up, which is 
>>>> annoying and illogical for the user.
>>>> 
>>>> If alternatively I wrap the performClick in a dispatch_async on the main 
>>>> thread (i.e. it should execute after the menu pops up) then something 
>>>> weird happens - the menu appears and then the Open dialog pops up (as I 
>>>> had hoped), but no file system items appear in there. I have a suspicion 
>>>> this has something to do with funny run-loop states when tracking menus, 
>>>> but I don't know what to do about it!
>>>> 
>>>> 
>>>> I don't know if what I am trying to do is an appropriate way of going 
>>>> about things, but hopefully it gives a clearer idea of what I am trying to 
>>>> achieve here (bring up the Open dialog, just as if the user had selected 
>>>> "Choose..." themselves). And hopefully somebody can suggest how I should 
>>>> tweak what I am doing so it behaves correctly?
>>>> 
>>>> Thanks again
>>>> Jonny
>>>> 
>>>> 
>>>>> On 15 Mar 2015, at 13:18, Jonathan Taylor <jonathan.tay...@glasgow.ac.uk> 
>>>>> wrote:
>>>>> 
>>>>> I have a dialog which allows the user to select a folder containing data 
>>>>> to be processed, set various parameters that affect the processing, and 
>>>>> displays the result of the analysis. There is an NSPathControl (popup) to 
>>>>> select the folder. Inevitably the first thing the user does is choose a 
>>>>> folder (and of course they have the option of changing this later). I 
>>>>> would like to simplify the workflow by automatically popping up the 
>>>>> "open" dialog when the main dialog is first opened, as if the user has 
>>>>> clicked on the path popup and selected "choose". However, I can't work 
>>>>> out an obvious way of triggering the path control to behave as if the 
>>>>> user has manually selected "choose" from the popup. 
>>>>> 
>>>>> Is there a way I can do that? I could of course throw up my own "open" 
>>>>> dialog and programatically set the URL associated with the path control, 
>>>>> but that seems like unnecessary duplication of code when I could just 
>>>>> call something like [myPathControl displayChooseDialog] (if such a method 
>>>>> existed!).
>>>>> 
>>>>> Can anyone suggest a way of doing what I want here? 
>>>>> 
>>>>> Thanks for any suggestions
>>>>> Jonny
>>>> 
>>>> _______________________________________________
>>>> 
>>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>>> 
>>>> Please do not post admin requests or moderator comments to the list.
>>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>>> 
>>>> Help/Unsubscribe/Update your Subscription:
>>>> https://lists.apple.com/mailman/options/cocoa-dev/dangerwillrobinsondanger%40gmail.com
>>>> 
>>>> This email sent to dangerwillrobinsondan...@gmail.com
> 

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to