Monday, November 20, 2017

#1 2017-08-01 02:41:09 pm

rubik
Member
Registered: 2017-05-31
Posts: 5

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?

Offline

 

#2 2017-08-01 06:34:51 pm

DJ Bazzie Wazzie
Member
From:: the Netherlands
Registered: 2004-10-20
Posts: 2724
Website

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

rubik wrote:

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.

Offline

 

#3 2017-08-01 10:47:07 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5177

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

rubik wrote:

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?



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


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#4 2017-08-30 01:38:42 am

Neophyte
Member
From:: Canberra, ACT, Australia
Registered: 2017-08-20
Posts: 21
Website

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

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]


Public servants are people too

Offline

 

#5 2017-08-30 02:37:18 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5177

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

Neophyte wrote:

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 ?



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

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


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#6 2017-09-02 08:33:31 pm

Neophyte
Member
From:: Canberra, ACT, Australia
Registered: 2017-08-20
Posts: 21
Website

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

Shane Stanley wrote:
Neophyte wrote:

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 ?

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 ?


Public servants are people too

Offline

 

#7 2017-09-02 09:18:22 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5177

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

Neophyte wrote:

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.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#8 2017-09-03 09:49:11 am

DJ Bazzie Wazzie
Member
From:: the Netherlands
Registered: 2004-10-20
Posts: 2724
Website

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

Neophyte wrote:

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 ?



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.

Offline

 

#9 2017-09-13 06:36:57 pm

Neophyte
Member
From:: Canberra, ACT, Australia
Registered: 2017-08-20
Posts: 21
Website

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

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


Public servants are people too

Offline

 

#10 2017-09-13 09:22:53 pm

DJ Bazzie Wazzie
Member
From:: the Netherlands
Registered: 2004-10-20
Posts: 2724
Website

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

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?

Applescript:


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()

Offline

 

#11 2017-09-22 02:05:38 am

Neophyte
Member
From:: Canberra, ACT, Australia
Registered: 2017-08-20
Posts: 21
Website

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

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].


Public servants are people too

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)