Hide custom plugins opening Script Editor

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

paulclaude
Posts: 121
Joined: Thu Mar 27, 2008 10:19 am

Hide custom plugins opening Script Editor

Post by paulclaude » Tue Mar 02, 2021 12:07 pm

Hello,
I have some personal plugins that, if opened, stay on front when I open the script editor, covering a part of it. Is there any way to hide them exactly as happens with the original Livecode palettes?
Thanks....

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Hide custom plugins opening Script Editor

Post by bogs » Tue Mar 02, 2021 12:44 pm

Not knowing in what way your using these (i.e., interacting with them, don't require interaction, etc), I'd probably say one of several things:
1. If you need to be able to interact with it on occasion, set the plugin's mode to modeless, which should allow the SE to be above it when your in the SE.
2. If you don't need to interact with it, set the visible of it to false or hide it on launch
3. If you sometimes need to use it, or whatever else really, you might try suspendStack.

Code: Select all

on suspendStack            -- hide a palette that only applies to this window
  hide stack "Accessories"
end suspendStack
Lastly, you could always iconify the stack. I know none of these are what is probably being used in the IDE itself, but I was really just too lazy to crack open the IDE to find out :P
Image

paulclaude
Posts: 121
Joined: Thu Mar 27, 2008 10:19 am

Re: Hide custom plugins opening Script Editor

Post by paulclaude » Tue Mar 02, 2021 1:06 pm

bogs wrote:
Tue Mar 02, 2021 12:44 pm
Not knowing in what way your using these (i.e., interacting with them, don't require interaction, etc), I'd probably say one of several things:
1. If you need to be able to interact with it on occasion, set the plugin's mode to modeless, which should allow the SE to be above it when your in the SE.
2. If you don't need to interact with it, set the visible of it to false or hide it on launch
3. If you sometimes need to use it, or whatever else really, you might try suspendStack.

Code: Select all

on suspendStack            -- hide a palette that only applies to this window
  hide stack "Accessories"
end suspendStack
Lastly, you could always iconify the stack. I know none of these are what is probably being used in the IDE itself, but I was really just too lazy to crack open the IDE to find out :P
Hi Bogs,
I only need to hide my palette when the script editor is in the foreground, and make my palette visible again when the script editor closes or fades to the background, just like the IDE does for Livecode's internal palettes ...

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Hide custom plugins opening Script Editor

Post by bogs » Tue Mar 02, 2021 1:11 pm

paulclaude wrote:
Tue Mar 02, 2021 1:06 pm
I only need to hide my palette when the script editor is in the foreground, and make my palette visible again when the script editor closes or fades to the background, just like the IDE does
bogs wrote:
Tue Mar 02, 2021 12:44 pm
I know none of these are what is probably being used in the IDE itself, but I was really just too lazy to crack open the IDE to find out
Image

paulclaude
Posts: 121
Joined: Thu Mar 27, 2008 10:19 am

Re: Hide custom plugins opening Script Editor

Post by paulclaude » Tue Mar 02, 2021 1:26 pm

I found a really inelegant but effective solution:

Code: Select all

on revEditScript
   send "hide stack " & quote & "Stack Collector" & quote to stack "Stack Collector" in 1 millisecond
   pass revEditScript
end revEditScript

on revResumeStack
   put the openStacks into op 
   if line 1 of op contains "revNewScriptEditor"
   then hide stack "Stack Collector"
   else show stack "Stack Collector"
   pass revResumeStack
end revResumeStack

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Hide custom plugins opening Script Editor

Post by bogs » Tue Mar 02, 2021 2:17 pm

Well, that certainly looks simpler than the code the IDE is actually using (*IF* this is the code, I *believe* it is :P )

Code: Select all

on revSEDelayTogglePalettes pShow
   lock screen
   
   local tOldLock
   put the lockMessages into tOldLock
   lock messages
   
   if pShow then
      if the iconic of stack revIDEPaletteToStackName("menubar") then exit revSEDelayTogglePalettes
      
      local tObject
      put the focusedObject into tObject
      if tObject is not empty then
         local tStack
         put revTargetStack(tObject) into tStack
         if tStack is "Answer dialog" or "revVariableWatcher" is in tStack or \
               "revMessageWatcher" is in tStack or revSEStackIsScriptEditor(tStack) then
            exit revSEDelayTogglePalettes
         end if
      end if
      
      local tHiddenStack
      repeat for each key tHiddenStack in sHiddenPalettes
         # OK-2009-10-08 : Its possible that the stack could be been removed between showing and hiding the palettes,
         # this is due to extra mutable windows added with the new script editor. Check this first or it will keep throwing
         # errors.
         if there is no stack tHiddenStack then
            next repeat
         end if
         show stack tHiddenStack
         if the mode of stack tHiddenStack is 0 then--Unix Window Managers 
            if word 1 of tHiddenStack is "revPropertyPalette" then 
               send "revUpdateTabs" to stack tHiddenStack
            end if
         end if
      end repeat
      
      delete variable sHiddenPalettes
   else
      if the mode of stack "revErrorDisplay" is not 0 and revIDEGetPreference("cSEHideErrors") then
         hide stack "revErrorDisplay"
         put empty into sHiddenPalettes["revErrorDisplay"]
      end if
      
      if the cSEHidePalettes of stack "revPreferences" then
         local tOpenStacks
         put the openStacks into tOpenStacks
         repeat for each line tStackName in tOpenStacks
            if not revIDEStackNameIsIDEStack(tStackName) then
               next repeat
            end if
            
            if not the visible of stack tStackName then
               next repeat
            end if
            
            if (tStackName is not among the items of kDontHide) and the mode of stack tStackName is 4 then
               # OK-2008-06-24 : Bug 6621 : Prevent palettes being hidden if they are owned by the script editor
               if the mainstack of stack tStackName is the short name of revScriptEditorMain() then
                  next repeat
               end if
               
               # OK-2009-12-22: Bug 8497 : Also keep separate variable viewer panes open
               if tStackName begins with "revVariableVisualizer" then
                  next repeat
               end if
               
               hide stack tStackName
               put empty into sHiddenPalettes[tStackName]
            end if
         end repeat
      end if
      -- must be after the others
      if the mode of stack "Message Box" is not 0 and revIDEGetPreference("cSEHideMessageBox") then
         hide stack "Message Box"
         put empty into sHiddenPalettes["Message Box"]
      end if
   end if
   
   set the lockMessages to tOldLock
   unlock screen
end revSEDelayTogglePalettes
Image

paulclaude
Posts: 121
Joined: Thu Mar 27, 2008 10:19 am

Re: Hide custom plugins opening Script Editor

Post by paulclaude » Tue Mar 02, 2021 3:02 pm

bogs wrote:
Tue Mar 02, 2021 2:17 pm
Well, that certainly looks simpler than the code the IDE is actually using (*IF* this is the code, I *believe* it is :P )

Code: Select all

on revSEDelayTogglePalettes pShow
   lock screen
   
   local tOldLock
   put the lockMessages into tOldLock
   lock messages
   
   if pShow then
      if the iconic of stack revIDEPaletteToStackName("menubar") then exit revSEDelayTogglePalettes
      
      local tObject
      put the focusedObject into tObject
      if tObject is not empty then
         local tStack
         put revTargetStack(tObject) into tStack
         if tStack is "Answer dialog" or "revVariableWatcher" is in tStack or \
               "revMessageWatcher" is in tStack or revSEStackIsScriptEditor(tStack) then
            exit revSEDelayTogglePalettes
         end if
      end if
      
      local tHiddenStack
      repeat for each key tHiddenStack in sHiddenPalettes
         # OK-2009-10-08 : Its possible that the stack could be been removed between showing and hiding the palettes,
         # this is due to extra mutable windows added with the new script editor. Check this first or it will keep throwing
         # errors.
         if there is no stack tHiddenStack then
            next repeat
         end if
         show stack tHiddenStack
         if the mode of stack tHiddenStack is 0 then--Unix Window Managers 
            if word 1 of tHiddenStack is "revPropertyPalette" then 
               send "revUpdateTabs" to stack tHiddenStack
            end if
         end if
      end repeat
      
      delete variable sHiddenPalettes
   else
      if the mode of stack "revErrorDisplay" is not 0 and revIDEGetPreference("cSEHideErrors") then
         hide stack "revErrorDisplay"
         put empty into sHiddenPalettes["revErrorDisplay"]
      end if
      
      if the cSEHidePalettes of stack "revPreferences" then
         local tOpenStacks
         put the openStacks into tOpenStacks
         repeat for each line tStackName in tOpenStacks
            if not revIDEStackNameIsIDEStack(tStackName) then
               next repeat
            end if
            
            if not the visible of stack tStackName then
               next repeat
            end if
            
            if (tStackName is not among the items of kDontHide) and the mode of stack tStackName is 4 then
               # OK-2008-06-24 : Bug 6621 : Prevent palettes being hidden if they are owned by the script editor
               if the mainstack of stack tStackName is the short name of revScriptEditorMain() then
                  next repeat
               end if
               
               # OK-2009-12-22: Bug 8497 : Also keep separate variable viewer panes open
               if tStackName begins with "revVariableVisualizer" then
                  next repeat
               end if
               
               hide stack tStackName
               put empty into sHiddenPalettes[tStackName]
            end if
         end repeat
      end if
      -- must be after the others
      if the mode of stack "Message Box" is not 0 and revIDEGetPreference("cSEHideMessageBox") then
         hide stack "Message Box"
         put empty into sHiddenPalettes["Message Box"]
      end if
   end if
   
   set the lockMessages to tOldLock
   unlock screen
end revSEDelayTogglePalettes
my little code has far less claims, actually... 😊

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Hide custom plugins opening Script Editor

Post by dunbarx » Tue Mar 02, 2021 3:26 pm

Hi.

Wouldn't it be simpler to show your plug-in stacks only when the visible of stack "newRevScriptEditor" is "false", and hide them when it is "true"?

Craig

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9801
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: Hide custom plugins opening Script Editor

Post by FourthWorld » Tue Mar 02, 2021 4:53 pm

Do the stacks really need to be palettes?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Hide custom plugins opening Script Editor

Post by bogs » Tue Mar 02, 2021 4:58 pm

That was what I was trying to get at earlier hee hee.
Image

paulclaude
Posts: 121
Joined: Thu Mar 27, 2008 10:19 am

Re: Hide custom plugins opening Script Editor

Post by paulclaude » Tue Mar 02, 2021 5:51 pm

FourthWorld wrote:
Tue Mar 02, 2021 4:53 pm
Do the stacks really need to be palettes?
Yes, they are custom plugins, they have to intercept messages and avoid going to the foreground
dunbarx wrote:
Tue Mar 02, 2021 3:26 pm
Hi.

Wouldn't it be simpler to show your plug-in stacks only when the visible of stack "newRevScriptEditor" is "false", and hide them when it is "true"?

Craig
No, it's always true, and anyway, you can't easily trap the changes.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Hide custom plugins opening Script Editor

Post by dunbarx » Tue Mar 02, 2021 6:29 pm

I have some personal plugins that, if opened, stay on front when I open the script editor, covering a part of it. Is there any way to hide them exactly as happens with the original Livecode palettes?
So now I am not sure what you are asking. If the plug-ins are visible, and you open the SE, what do you want to happen to them? To disappear behind the SE? To move out of the way?

Anyway, why do your plugins have to be visible? They will work just fine if not.

Craig

paulclaude
Posts: 121
Joined: Thu Mar 27, 2008 10:19 am

Re: Hide custom plugins opening Script Editor

Post by paulclaude » Tue Mar 02, 2021 6:50 pm

dunbarx wrote:
Tue Mar 02, 2021 6:29 pm
I have some personal plugins that, if opened, stay on front when I open the script editor, covering a part of it. Is there any way to hide them exactly as happens with the original Livecode palettes?
So now I am not sure what you are asking. If the plug-ins are visible, and you open the SE, what do you want to happen to them? To disappear behind the SE? To move out of the way?

Anyway, why do your plugins have to be visible? They will work just fine if not.

Craig
I'm sorry not to explain clearly. I have plugins (palette stacks) that MUST remain open and visible all the time, but, as with Livecode palettes (Tools, etc.), they must temporarily become invisible when using the Script Editor.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Hide custom plugins opening Script Editor

Post by dunbarx » Tue Mar 02, 2021 7:27 pm

OK.
they must temporarily become invisible when using the Script Editor.
Does that mean "when the SE is open", or when the cursor is within its rect?

I keep the SE open virtually always, so I can imagine having small stacks peppered all over it. And I know that it is not easy to detect when the cursor is within the rect of the SE.

Maybe have a keyboard shortcut that shows and hides the plugIns? I have a bunch of these, and they work great.

Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9567
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Hide custom plugins opening Script Editor

Post by dunbarx » Tue Mar 02, 2021 7:32 pm

Been a long time since I used the "idle" message, but might this do: in the card script:

Code: Select all

on idle
   if the mouseLoc is  within the rect of this cd  then showYourPlugIns else hideYourPlugIns
end idle
This does nothing for you if you merely want to glance at the contents of the SE as opposed to actually working there.

Craig

Post Reply

Return to “Talking LiveCode”