Top bar will not appear

(Jonas Whale) #1


At random times, the top bar is not showing.
Did you see that?


(Shane Stanley) #2

Are you running that from an app?

(Jonas Whale) #3

Just playing with code in SD 6.0 (on Yosemite).

As we are talking about running the script from an app:
I have inserted the code for the dialog in my precedent post in a script that imports a text box from Indesign to Powerpoint.
The script is launched with a shortcut from FastScript while PPT is the frontmost application.
The icon displayed in the dialog is the FastScript’s one.
Can’t we have the PPT icon instead (I mean the one from the current app)?

(Shane Stanley) #4

You can use pretty much any image you like. Just insert code like this:

set anImage to current application's NSImage's alloc()'s initWithContentsOfFile:pathToSomeImage
theAlert's setIcon:anImage

(Jonas Whale) #5

I’m lost.

How to get the current app’s icon?
Where must go your two lines of code
The script below triggers this error:
NSImage does not understand the message « alloc »

[code]use AppleScript version "2.4"
use scripting additions
use script “Dialog Toolkit” version “2.0”

property NSImage : class “NSImage”

set pathToSomeImage to POSIX path of "LaCie 1:Icones en cours:••Apps Diverses••:PPT3.icns"
set anImage to current application’s NSImage’s alloc()'s initWithContentsOfFile:pathToSomeImage
theAlert’s setIcon:anImage
set alertText to "Veuillez régler le comportement du bloc de texte."
set alertMess to “Les marges intérieures seront supprimées.” & return
set {check1, theTop, newWidth} to create checkbox “Renvoyer le texte à la ligne” left inset 120 bottom 0 max width 400 without initial state
set {check2, label2, theTop, newWidth} to create labeled checkbox “Ajuster le bloc au texte” left inset 0 bottom (theTop + 8) max width 400 label text “Options” checkbox left 120 without initial state
set {popup3, label3, theTop} to create labeled popup {“Haut”, “Milieu”, “Bas”} left inset 0 bottom (theTop + 8) popup width 180 max width 400 label text “Alignement vertical” popup left 120

set allControls to {check1, label2, check2, label3, popup3}
set {buttonName, suppressedState, controlsResults} to display enhanced alert alertText message alertMess as informational alert buttons {“Aide”, “Annuler”, “OK”} giving up after 120 acc view width 400 acc view height theTop acc view controls allControls without suppression
if buttonName = “Annuler” then return[/code]

(koenigyvan) #6

My understanding is that you must add the instruction :
use framework "Foundation"
at the beginning of your script.

I can’t guarantee because, if the instruction :
set anImage to current application’s NSImage’s alloc()'s initWithContentsOfFile:pathToSomeImage
is correctly executed, the script fails to execute the instruction :
theAlert’s setIcon:anImage
with the message : error “La variable theAlert n’est pas définie.” number -2753 from “theAlert”

It seems that the instruction : property NSImage : class “NSImage” is not required.

Yvan KOENIG running El Capitan 10.11.6 in French (VALLAURIS, France) samedi 23 juillet 2016 11:37:01

(Shane Stanley) #7

Sorry, I wasn’t clear – you’d need to make that change to the library itself, within the main handler.

But unless you’re happy doing that, I’m afraid the answer is that you’re out of luck. One of the things with interfaces is that there are so many options, if you add them all it becomes much more complex to use.

I’ll keep the option in mind for future versions.

(Matt Strange) #8

The original question about toolbar visibility is not really related to Dialog Toolkit. I don’t use that, and I just saw the same issue. Quit and relaunch fixed it.

I spent a few minutes trying to reproduce it based on what I had been doing, but could not. Possibly random.

Edit: I assumed the original question meant to say tab bar, but maybe something else was intended. Either way, I just had a situation where the tab bar didn’t appear, even though multiple tabs were open. I could switch tabs via keyboard or Window menu, but there was no tab bar visible, and the menu item “Hide Tab Bar” was disabled so I couldn’t toggle it.

(Jonas Whale) #9


Matt, It’s just about the bar you see at top the the alert window. Like this one:

In my previous post, you can see there’s no such bar…