Can the X-Y coordinates of a Dialog Toolkit dialog be specified?

I would like a Dialog Toolkit dialog to appear in the lower-right-hand corner of the screen (instead of sitting in the center of the screen).

Is this feasible?

Yes, if you create the panel window with ASObjC you can set the location of a panel anywhere you want. However, the standard addition (display dialog command) is injected into a target application if setm which is impossible with ASObjC. You can only show a panel in the current application context in ASObjC.

Not using Dialog Toolkit, no. It 's still an alert, and therefore appears where all alerts appear.

I have the same problem but with multiple dialogs shown by separate processes – and so each is obscured by the next the dialog to be shown.

Would it be feasible, after the dialog is displayed, to use GUI scripting to grab the dialog window title bar and move it to a given location on the screen ?

[Acknowledging that this probably means creating another process that can run at the same time as the dialog is visible and open for interaction]

In theory, I suppose. But it sounds pretty awful.

It sounds like you need panels instead, as DJ suggested.

Yes, would be ugly. But the thought of learning ASOC to do one dialog is a bit daunting. The problem is that I’ve used 16 scripting languages over the last 30 years without delving into a real language. Is AppleScriptObjC as easy as AppleScript ?

It’s not so much the language you have to learn as how the frameworks work – a bit like AppleScript versus how apps implement it.

And getting into UI stuff is quite a jump.

Your experience would help you. It’s a bridge, not a programming language or a superset. The most difficult part is would be to understand the different paradigms of Objective-C and AppleScript which also cause its limitations and quirks. When you know 16 different scripting languages you understand the concept op programming and practiced different disciplines (paradigm). So I don’t think it would be difficult at all for you.

DJ, many thanks. I’ll give it a go.

Here an example to start with maybe. It’s an draft which I send to someone recently (pm about AST requests) to explain why AppleScript Toolbox shouldn’t have enhanced dialogs and it should be done with AppleScriptObjC for full control and customization. Anyway, this example may be useful to start with for you?


use AppleScript version "2.4"
use framework "Foundation"

property NSWindowController : class "NSWindowController"
property NSWindow : class "NSWindow"
property NSTextField : class "NSTextField"
property NSProgressIndicator : class "NSProgressIndicator"
property NSFont : class "NSFont"

set windowSize to current application's NSMakeRect(0, 0, 500, 80)
set aWindow to NSWindow's alloc()'s initWithContentRect:windowSize styleMask:7 backing:2 defer:yes
set wController to NSWindowController's alloc()'s initWithWindow:aWindow
aWindow's |center|()
aWindow's makeKeyAndOrderFront:me

set boldSystemFont to NSFont's boldSystemFontOfSize:12

set titleFieldSize to current application's NSMakeRect(20, 50, 460, 20)
set titleField to NSTextField's alloc()'s initWithFrame:titleFieldSize
titleField's setStringValue:"Insert Title of Job here…"
titleField's setFont:boldSystemFont
titleField's setBezeled:no
titleField's setDrawsBackground:no
titleField's setSelectable:no
titleField's setEditable:no

aWindow's contentView()'s addSubview:titleField

set infoFieldSize to current application's NSMakeRect(20, 30, 460, 20)
set infoField to NSTextField's alloc()'s initWithFrame:infoFieldSize
infoField's setStringValue:"Information about process"
infoField's setBezeled:no
infoField's setDrawsBackground:no
infoField's setSelectable:no
infoField's setEditable:no

aWindow's contentView()'s addSubview:infoField

set progressSize to current application's NSMakeRect(20, 10, 460, 20)
set progress to NSProgressIndicator's alloc()'s initWithFrame:progressSize
progress's setIndeterminate:no
progress's setMinValue:0.0
progress's setMaxValue:10.0
progress's setDoubleValue:5.0


aWindow's contentView()'s addSubview:progress

aWindow's setViewsNeedDisplay:yes
aWindow's displayIfNeeded()
aWindow's display()

Many thanks, this should push me along.

I’m looking for a way to display multiple progress bar windows/dialogs each tracking a shell process, that don’t overlap, have two buttons (Close Window and Cancel Process) and which close automatically when their process is finished.

The Close Window button would close the dialog leaving the process concerned to continue until it’s finished. It’s not critical but would be good to have. The close window gadget would be fine instead. The Cancel Process button cancels the process and does a tidy-up.

Have looked at SKProgress and Shane Stanley’s dialog toolkit but can’t figure out how to combine them to achieve the goal. At present, it looks like all I can do is open dialogs which don’t overlap and have the two buttons but which have no progress and automatically close after a set time.

AppleScriptObjC can do what I need so, I’ll start learning.

Cheers.

P.S. I reckon the easiest script to learn was AREXX, followed closely by VBA [except VBA on the Mac always has bugs].