I have a script that produces a list of posix paths in a text view with a scroller. I can select one, then open it with the Services > Finder > Open selection. However, I’d like to be able to double-click on the posix path and then tell the Finder to open the file, easy enough, or even just use “do shell script” to open the POSIX path.
Which handler would be appropriate? “On double clicked theObject?”
Or are selections in a text view not considered “objects,” – is what I am afraid of.
Are you really using a text view, or are you actually using a table view?
If you’re using a text view, then you don’t have a lot of options when it comes to first responder and conflicts with text views… as qwerty:) mentioned. If you have text selected in the text view, then it is first responder, and will react to any key input, such as hitting return. You could make the text field non-editable but selectable… which would keep it from responding to keyboard input… but then you’d still have to find a mechanism for capturing key presses or other actions. I think qwerty has the right idea, but I would take it another next step. Use the key equivalent of a button to act as your responder. Set up a button with a key equiv of , cmd+g, or whatever, and then use that as your input mechanism. It should always respond to whatever you set it to, and will give the appearance that the text view is actually responding to the input. Use the button’s ‘on clicked’ handler to capture the action. You can hide the button off screen or behind your text view so it’s not in view if that’s what float’s your boat… although that conflicts significantly with apple’s design guidelines. You should always have a ui element for every key equivalent, so perhaps leaving the button on screen, or using a app menu item for this would be better.
If you’re displaying lists of items, you may be better suited by using a table view. Although harder to set up, it is more intuitive, and designed for this purpose. You could then use the ‘double-clicked’ handler of the table view to capture the mouse input and write code to have the finder handle the path.