dock AS palette location to another application's window

Background:
I have a floating window - well, really it’s an AS Studio app with an invisible window and title, containing just a single button. So, it looks like just the “button” is floating above an application.

Problem:
I would like to fix or attach my “button” (invisible window) to a specific location of another open document/application (“Pages”).

Q. How do I dock, or attach my “button” to the frontmost document of “Pages” so that when the document is moved or resized, my button stays put relative to the open document window? ie. My “button” will look like another icon at the top of the document. But, if the “Pages” document is drag around on the screen, resized or even draged to a second monitor, the icon will move with the document. I would like no lag with the mouse down drag event. I really want this “button” FIXED to the document.

Anyone have any ideas?

Not sure that this can be done. First off, dragging the window in Pages won’t send any kind of event to your AS Studio application. Without an event, you can’t trigger movement of your window.

I’m curious how you got your window to be hidden with the button visible? Not sure what I’d do with it, but someone would find a use for it, no doubt.

The kind of thing you’re trying to do might be possible in Cocoa (with a custom window definition), but even then you’d have to hack up your copy of Pages to get it to work, I’d expect. You’d need to “implant” your version of the window in Pages’ nib file.

To create a transparent window in Applescript Studio: ie. a floating button

  1. Create a new project AS Studio app.

  2. Open Interface Builder (IB) by clicking the MAINMENU.NIB icon in your new project.
    Click the “Window” icon in your “Instances” tab. Now click the “Classes” tab and select “NSWindow”
    Now go to the menu bar; Under “Classes”, select SubClass NSWindow. A new class called MyWindow appears. Rename this to TPWindow (Transparent Window).
    Make sure TPWindow is selected. Go back to the menu bar under Classes and choose; Create files for TPWindow.

  3. Back in Xcode; import Existing Files TPWindow.h TPWindow.m under the Action pop up (icon looks like a gear).

  4. Back to IB ;click Window; drag a button onto it for a test; and cmd-5 to view the window inspector; choose TPWindow instead of NSWindow.

  5. NOW: Back in Xcode. Replace everything in TPWindow.m with the following:

Build and GO! You should now a button on your screen with now window. Play with the parms below. You can even create masks for irregular shaped windows - your company logo for instance. Credit for this goes to an applescript book author whose name escapes me right now.