Buttons in draggable vpgrid ignore drag attempts

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
strayerror
Regular
Posts: 159
Joined: Fri Jan 04, 2019 3:44 pm
Contact:

Buttons in draggable vpgrid ignore drag attempts

#1 Post by strayerror »

The setup:

- Picture a large grid of buttons, let's say for example 10x10, 100 buttons.
- There's space enough screen space to show a 5x4 subset.
- It's the basis for a puzzle where the goal is to find the "correct" button.
- I would like to be able to use draggable True on the vpgrid.
- All the buttons should have a hover effect.

The problem:

- Seemingly the only way to have a button respect hover is to assign an action, an alternative action is not enough.
- Indeed without action the alternate setting doesn't even function.
- With an action assigned (even a NullAction()), the mouse events that would cause the drag get swallowed and it's not possible to drag except by grabbing part of the grid between buttons. Which isn't viable without causing massive player confusion.

The code:

Code: Select all

screen the_grid():
    default goal = renpy.random.randint(0, 99)

    vpgrid:
        rows 10
        cols 10
        draggable True

    vpgrid:
        rows 10
        cols 10
        draggable True

        for i in xrange(0, 100):
            textbutton '[i]':
                action NullAction() # commenting this makes it draggable but disables the buttons
                alternate If(i == goal, Return('you win'), NullAction())
                background ('#fcc' if i == goal else '#ccc')
                hover_background '#cfc'
                text_color '000'
                xysize (config.screen_width / 5, config.screen_height / 4)
Thanks for reading!

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: Buttons in draggable vpgrid ignore drag attempts

#2 Post by rayminator »

you want use this one if I have read your post right that you want to drag something from the left to the right
https://www.renpy.org/doc/html/drag_dro ... =draggable

strayerror
Regular
Posts: 159
Joined: Fri Jan 04, 2019 3:44 pm
Contact:

Re: Buttons in draggable vpgrid ignore drag attempts

#3 Post by strayerror »

Unfortunately I don't believe drags behave differently in this regard. The button would still swallow the drag attempt. Additionally as drags unconditionally render all content it would also incur a hefty performance cost when compared to the vpgrid which renders only children that will appear on screen to allow for smoother performance. Appreciate the suggestion though.

Post Reply

Who is online

Users browsing this forum: Bing [Bot]