ShowClipboard Hotkey

First a note: If you have an image on the clipboard and you use the clipboard( function as part of a formula in a Text Display Object it will crash Panorama X. In Panorama 6 it would show the Text Display object as blank but not crash. If you assign the clipboard() containing an image to a variable it will set the variable to “” in 6 but in X it will stop the procedure but not issue an error.

I ran across this problem when I was making a Hotkey to replace the missing ShowClipboard statement in Panorama 6. Yes, there is a ShowClipboard statement available in Panorama 6 even though it is not listed in the Panorama Reference file. I often used that statement to check the contents of the clipboard and have missed it in Panorama X.

I did find a way to check the contents of the clipboard via AppleScript that will tell me if the contents are text so I don’t crash Panorama X if it contains an image. Once that problem was overcome, I proceeded to create a Hotkey to show the text contents of the clipboard. The code creates a new form with a Text Display Object and a Push Button so it can be used to display the clipboard text as a sheet in the current window. Once the “Ok” button is pressed in the form the “Clipboard” form is deleted. I added the new Hotkey code to my .InitializeFunctions procedure in my custom Library file so that it is executed automatically as Panorama starts up. Now, in any window, I can click control-shift-C to see what text is on the clipboard. Here is the code:

definehotkeys "Global", "SHIFT-CONTROL-C",
    |||applescript {set the clipboard to (the clipboard as string)}
If error
     alertsheet "Clipboard does not contain text!","icon",
         bundleresourcepath("RedBangCircle14px.tiff")
     stop
endif
If clipboard()=""
    alertsheet "Clipboard is empty!","icon",
        bundleresourcepath("RedBangCircle14px.tiff")
    stop
endif
//letfileglobal fakePadding=""
local targetFormName
define targetFormName,"Clipboard"
makenewform targetFormName

letglobal dlgResult=""
loop
    rundialog {
        Form="Clipboard"
        File=""
        sheet=true
        Menus=normal
        Height=500 Width=600
    }
    stoploopif info("trigger")="Dialog.Close"
        if info("trigger") = "Dialog.Initialize"
            makeFormObjectsFromBluePrint:
            
            newformobject "TextDisplayObject",
                "rectangle",rectanglesize(1, 1, 430, 596),
                "Formula","clipboard()",
                "$TextDisplayFormulaMode","Formula",
                "$TextDisplayThinScroll","1",
                "$TextDisplayBorderStyle","Bezel",
                "$TextDisplayAutoHideScroll","0",
                "$TextDisplaySelectable","1",
                "$TextDisplayVerticalScroll","1"
                
            newformobject "PushButtonObject",
                "rectangle",rectanglesize(438, 475, 26, 100),
                "Procedure","resume {}",
                "$PushButtonDefaultButton","1",
                "Title","Ok"
            selectnoobjects
    endif
    if dlgResult="Ok"
        setformoptions "","Clipboard","DELETE",""
        if error
            closewindow
        endif
    endif
endloop
|||

i have included a couple of warnings in case there is an image on the clipboard or the clipboard is empty. The trigger keys for activating this Hotkey can be set to anything you prefer.

Thanks Gary. I have found the bug in the clipboard() function and fixed it, so in the next release it will work ok. In the meantime, your clever workaround may be useful to someone.