[Solved]Hiding an imagebutton while sliding at it

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Doeny
Regular
Posts: 145
Joined: Wed Sep 07, 2022 8:28 pm
Contact:

[Solved]Hiding an imagebutton while sliding at it

#1 Post by Doeny »

So basically what i'm trying make is a code that detects if left mouse button is holded and then imagebutton's hovered so it can return an action, but can't make it go right. Any ideas on that one?

Code: Select all

screen field:

    key 'mousedown_1' action SetVariable('mouse_pressed', True)
    key 'mouseup_1' action SetVariable('mouse_pressed', False)


    vbox:

        spacing 25

        imagebutton:
            idle "target"
            
            if mouse_pressed == True:
                 hovered Jump("target_hit")
Last edited by Doeny on Sat Nov 26, 2022 8:04 am, edited 1 time in total.

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Hiding an imagebutton while sliding at it

#2 Post by _ticlock_ »

Doeny wrote: Mon Nov 21, 2022 1:04 pm
It's related to viewtopic.php?f=8&t=65680#p556548

The code you suggested does not work for 2 reasons:

1) the button is not sensitive. hovered action is not triggered if the button is not sensitive. You can fix it, for example, with

Code: Select all

action NullAction()
2) hovered action is triggered only when the button state is changed from idle to hover. If you are hovering over the button and then press the mouse, it is not going to trigger hover action.

There is also potential problem with using key 'mouseup_1'. It will prevent to trigger button action, the key action will be triggered instead.

Doeny
Regular
Posts: 145
Joined: Wed Sep 07, 2022 8:28 pm
Contact:

Re: Hiding an imagebutton while sliding at it

#3 Post by Doeny »

_ticlock_ wrote: Mon Nov 21, 2022 3:18 pm
Doeny wrote: Mon Nov 21, 2022 1:04 pm
It's related to viewtopic.php?f=8&t=65680#p556548

The code you suggested does not work for 2 reasons:

1) the button is not sensitive. hovered action is not triggered if the button is not sensitive. You can fix it, for example, with

Code: Select all

action NullAction()
2) hovered action is triggered only when the button state is changed from idle to hover. If you are hovering over the button and then press the mouse, it is not going to trigger hover action.

There is also potential problem with using key 'mouseup_1'. It will prevent to trigger button action, the key action will be triggered instead.
So I solved the first reason, the 2nd one is made on purpose, so you have to start clicking off-button (or however you can describe that), but do you have any ideas on how to bring the 3rd one, the trigger button to work?

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: Hiding an imagebutton while sliding at it

#4 Post by _ticlock_ »

Doeny wrote: Mon Nov 21, 2022 4:46 pm the 2nd one is made on purpose, so you have to start clicking off-button (or however you can describe that)
I haven't realized that this behavior actually works for you.
Doeny wrote: Mon Nov 21, 2022 4:46 pm how to bring the 3rd one, the trigger button to work?
You can use capture property. In this case, if the key action does not end the interaction the event will be passed to other displayables:

Code: Select all

key 'mouseup_1' action SetVariable('mouse_pressed', False) capture False

Post Reply

Who is online

Users browsing this forum: No registered users