Old 03-24-2020, 06:21 PM   #1
cohler
Human being with feelings
 
Join Date: Dec 2018
Posts: 93
Default Prevent user from closing Window

Using the Lokasenna GUI is there a way to prevent a user from closing a window with the window close button unless he clicks or sets a certain setting in the window first?

In other words, to force the window to stay open and ignore his click on the x box unless he does something requested in the window?
cohler is offline   Reply With Quote
Old 03-24-2020, 11:27 PM   #2
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 2,034
Default

In general, this would be bad UI-design. What is the usecase for this?

You could prevent it, if you use Julian's extension and, I think, this function: https://mespotin.uber.space/Ultrasch...JS_Window_Show

That way, you can hide the titlebar and therefore the close-button.
__________________
Pronounce me with she/her, when referencing me, please. Thanks :)
Ultraschall-API - 1111 ReaScript functions for Reaper
Reaper Internals - Developerdocs4Reaper
mespotine is offline   Reply With Quote
Old 03-24-2020, 11:53 PM   #3
pandabot
Human being with feelings
 
pandabot's Avatar
 
Join Date: Oct 2018
Posts: 172
Default

Instead you should track the user's mouse coordinates in order to move the window position whenever the mouse cursor gets too close to the X, so the window can escape being terminated
pandabot is online now   Reply With Quote
Old 03-25-2020, 12:00 AM   #4
FeedTheCat
Human being with feelings
 
FeedTheCat's Avatar
 
Join Date: May 2019
Posts: 37
Default

Quote:
Originally Posted by mespotine View Post
What is the usecase for this?
Oh, it's just a tiny little COHLER CLASSICAL banner, nothing to worry about here
FeedTheCat is offline   Reply With Quote
Old 03-25-2020, 12:48 PM   #5
cohler
Human being with feelings
 
Join Date: Dec 2018
Posts: 93
Default

Quote:
Originally Posted by mespotine View Post
In general, this would be bad UI-design. What is the usecase for this?

You could prevent it, if you use Julian's extension and, I think, this function: https://mespotin.uber.space/Ultrasch...JS_Window_Show

That way, you can hide the titlebar and therefore the close-button.
The use is to force them to make a choice in the menu before exiting the window.
cohler is offline   Reply With Quote
Old 03-25-2020, 02:01 PM   #6
pandabot
Human being with feelings
 
pandabot's Avatar
 
Join Date: Oct 2018
Posts: 172
Default

The user might be able to anticipate the window movements if the logic is too simple, so I’d also recommend building a randomized "juking algorithm" with feints and misdirections
pandabot is online now   Reply With Quote
Old 03-25-2020, 02:35 PM   #7
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 556
Default

+1 @pandabot

You obviously have considerable experience in software development and programming.

Let's collab
__________________
My Scripts
Dafarkias is offline   Reply With Quote
Old 03-25-2020, 02:57 PM   #8
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,681
Default

Moving a window around so a user can't click on something is just silly IMO! Have to agree with mespotine, I would just hide the title bar and then display the titlebar text near the top of the window in a label or whatever.

So for example to remove title bar from Lokasenna v2 GUI example script, "Script: Example - Typical script options.lua" I added code to bottom like this, works in Windows 10...

Code:
GUI.Init()
GUI.Main()
-- Edgemeal added, to remove titlebar,.. 
-- by lb0, https://forum.cockos.com/showpost.php?p=2178359&postcount=696
local window = reaper.JS_Window_FindTop(GUI.name, true)
if window then
  local style = reaper.JS_Window_GetLong(window, "STYLE")
  style = style & (0xFFFFFFFF - 0x00C40000) -- remove title and border bits
  reaper.JS_Window_SetLong(window, "STYLE", style)
  reaper.JS_Window_Resize(window, GUI.w, GUI.h) -- workaround (controls incorrect location)
end
Requires js_ReaScriptAPI extension,
https://forum.cockos.com/showthread.php?t=212174

Last edited by Edgemeal; 03-25-2020 at 04:23 PM. Reason: workaorund, some controls not shown in original locations
Edgemeal is online now   Reply With Quote
Old 03-26-2020, 05:37 AM   #9
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 556
Default

if you didn't want to use JS Extension you could always just reinitialize the window if a user closes it. It's definitely not an ideal workaround, but it is an option.
__________________
My Scripts
Dafarkias is offline   Reply With Quote
Old 03-26-2020, 05:43 AM   #10
Dafarkias
Human being with feelings
 
Dafarkias's Avatar
 
Join Date: Feb 2019
Location: England
Posts: 556
Default

Oooorrrrrr: reaper.GetUserInputs()

That might work. Depends on the use case.
__________________
My Scripts
Dafarkias is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:24 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.