How can I make a floating panel to be used by another application,
without bringing my ASS application to the front when I click in the
panel?
I am using XCode 1.5, including Interface Builder 2.4.2 (v364), on Mac
OS X 10.3.6.
OK, this seems to be one of the most frequently asked questions in this
mail list, and I've searched emails back a couple of years, with no
working solution.
All I've found is that I should:
1. In the inspector for the panel, set the Attributes "Utility Window
(Panel only)" to true, "Non Activating Panel" to true.
2. To get around the auto setting of the "Hide on Deactivate" attribute
to true, I connected an AppleScript handler for "awake from nib" to:
on awake from nib theObject
set hides when deactivated of theObject to false
end awake from nib
3. To make the panel show only when in my desired application (in my
case AppleWorks), I added an idle handler in my main script:
property panelIsActive : true
on idle theObject
set panelShouldBeActive to false
tell application "System Events"
if exists process "AppleWorks 6" then
if frontmost of process "AppleWorks 6" or frontmost of process
"Office Apprentice" then
set panelShouldBeActive to true
end if
end if
end tell
if panelShouldBeActive is not panelIsActive then
if panelShouldBeActive then
set hides when deactivated of window "Panel" to false
show window "Panel"
else
set hides when deactivated of window "Panel" to true
hide window "Panel"
end if
set panelIsActive to panelShouldBeActive
end if
return 1
end idle
Is there a better way to do anything I've done so far?
With the above, what I have is a panel that displays only when
AppleWorks or itself are the frontmost applications.
But my problem is that when I click on a button in my floating utility
window, it switches to my ASS app as frontmost, showing its default
menus and so on. Some of my scripts require AppleWorks to be frontmost
and I can't just activate AppleWorks, since that flashes up one menu
bar then another, makes built in palettes disappear and reappear, and
it brings all of AppleWorks windows to the front.
I tried making my ASS app a faceless background app by sticking the
property:
LSUIElement string 1
In the info.plist file within the built application.
That seems to make it faceless, and the panel appears when I bring
AppleWorks to the front. And when I click in the panel, the menu bar
still shows AppleWorks' menus. But AppleWorks built in tool palette
disappears, and asking AppleWorks if it is frontmost returns "false".
And the script in my panel that requires AppleWorks to be frontmost,
fails.
Then I tried instead:
LSBackgroundOnly string 1
Slightly better results, in that the built in palettes do not disappear
when I click in my panel, and AppleWorks shows frontmost as 'true", but
although AppleWorks' menu is visible, it is disabled, and keystrokes go
to my panel instead of the application it serves (AppleWorks).
How can I make a floating panel that will still allow other apps to be
frontmost and receive keyboard focus, when the panel is used?