• To improve security, we will soon start forcing password resets for any account that uses a weak password on the next login. If you have a weak password or a defunct email, please update it now to prevent future disruption.

Ren'Py avoid mouse-actions on partially concealed screen

f95zoneuser463

Member
Game Developer
Aug 14, 2017
219
1,017
I'm working on a reusable and customizable GUI for computers. Everything is done in Ren'Py-screen-code, except for the icons. The icon is a . The problem is the __is_hit__()-function of my icon. The purpose of this function is to detect whether the icon is being hovered with the mouse. It only checks for an area and is unaware of potential other screens that would prevent hovering/clicking the icon.

The icon behind the texteditor is still "hoverable" (is that a word?) and clickable. That's the problem.
Since Ren'Py internally has to deal with the same problem when it renders multiple screens there must be a way to handle hovering/clicking the same way.

In general the GUI can have a maximum of 2 'virtual' windows open. I use Ren'Py's tag-system for that. It allows only one window/screen per tag to be open.
  • Files, Recycle Bin, Updates, Ultron, Firetail, Anti Virus will open screens tagged as apps
  • Photos, Text and other popups are tagged as file
What you are looking at are 3 screens (ignoring hud in the corners):
  • pc-screen with the background-image and icons on the left
  • pc-files-screen with the icons 'toys' and 'Emily' tagged as app
  • pc-text-screen showing the 'Texteditor KeLoga' tagged as file
You don't have permission to view the spoiler content. Log in or register now.
Texteditor-screen/window made transparent for demonstration:
wip pc gui.png
 

Rich

Old Fart
Modder
Respected User
Donor
Game Developer
Jun 25, 2017
2,472
6,940
Is the idea that when the text editor is up, you can only interact with it, and not with anything else on the screen? If so, you should make the text editor screen "modal" ("modal True" in screen language). This will prevent clicks from being "delivered down" to things behind it until the screen is dismissed.

Or are you simply trying to have the text editor eat clicks that are over it without interfering with clicks on other areas of the screen?
 

Epadder

Programmer
Game Developer
Oct 25, 2016
568
1,058
I was thinking modal might work @Rich, but using the pattern below to clarify how modal works.:

If Orange is a screen with modal set.
If Purple Checkerboard is a bunch of small screens (Icons) or If the Purple Checkerboard is a screen with many imagebuttons.
If Blue is the screens/imagebuttons overlapped by Orange.

What can still be interacted with?
modal-pattern.jpg
 

f95zoneuser463

Member
Game Developer
Aug 14, 2017
219
1,017
What can still be interacted with?
Only the orange screen.

Or are you simply trying to have the text editor eat clicks that are over it without interfering with clicks on other areas of the screen?
The text editor needs to 'eat' all click-/hover-events to icons that are below it.
or to look at this from the perspective of my 'pc_icon':
My icon needs to ignore events for all x/y-position that are covered by another screen like the text editor.

Modal is not what I'm looking for since it would block interactions with the icons on the left or the 'X'-button on the window behind the text editor. (unless there is some kind of mask-trick that I don't know about or something)
I've already tested it with modal, yes it works, but I think it's somewhat counter-intuitive to show clickable things that won't work due to the modal-flag. If everything fails I can still fall back to this together with a dimmed background "#0008" or allow only 1 open window by giving them all the same tag.

The icons on the left should be clickable all the time. When clicked they all have a function like this one to show/hide a screen:
Python:
def pc_files(icon):
    if renpy.get_screen("s_pc_files") == None:
        renpy.transition(fastdissolve)
        renpy.show_screen("s_pc_files")
    else:
        renpy.transition(fastdissolve)
        renpy.hide_screen("s_pc_files")
    renpy.restart_interaction()
A screen like s_pc_files taggad as app and can contain new icons (folders/files), it's like an explorer window.
A screen like s_pc_text tagged as file never contains new icon.
All app- and file-screens are at fixed position and cannot cover the icons on the left. A file-screen like the text editor can cover an app-screen or the other way around where for example the Firetail-browser-screen (app) would be above the text editor-screen (file). The last case is never a problem since file-screens never hold icons.

Is it possible to get a screen by a tag and then get it's area? Then I could use that to block some events maybe. But that's still 'hackish' ... hmm I want to know how Ren'Py does this.
 
Last edited:

Rich

Old Fart
Modder
Respected User
Donor
Game Developer
Jun 25, 2017
2,472
6,940
OK, one potential approach:
1. Use a modal screen
2. Have that screen obscure everything behind it (i.e. have it have the desktop background)
3. Include the elements that need to be active (e.g. all the other icons) in that screen, but omit the ones that shouldn't.
Thus, you get the appearance of having brought up just the text editor, when, in fact, you've brought up an entirely new screen. You can structure things like the icons on the left that need to appear on multiple screens into separate screens and pull them in via "use".

I tend to use this approach - I create "building block" screens that are designed to be "use"d inside "top-level" screens. That way you don't have to repeat logic over and over again, but you also get to isolate functionality. (I like many smaller, focused screens and files rather than large "garbage can" ones.)

Or, perhaps the simpler approach is just to have your text editor screen set a variable when it is shown, reset it when it's hidden, and have that variable cause the underlying screen to either hide the icons that are behind it, or disable their actions so that "click throughs" there don't do anything.