I have a big button and I want to find out where it has been clicked in relation to it's top left.
So far I've been positioning it manually, that way I know where my button starts at all times, this limits the use of vbox, hbox, paddings and drags. I wonder is there's an easy way to find where on the button has been clicked, or at least where the button was when it was clicked?
[solved] get click position on the button?
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.
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.
- Kia
- Eileen-Class Veteran
- Posts: 1050
- Joined: Fri Aug 01, 2014 7:49 am
- Deviantart: KiaAzad
- Discord: Kia#6810
- Contact:
[solved] get click position on the button?
Last edited by Kia on Sun Apr 28, 2024 11:42 am, edited 1 time in total.
- m_from_space
- Eileen-Class Veteran
- Posts: 1000
- Joined: Sun Feb 21, 2021 3:36 am
- Contact:
Re: get click position on the button?
I guess you could just call a function the moment it is clicked. That function then utilizes renpy.get_mouse_pos() and calculates the rest depending on the position of the button and its size.Kia wrote: ↑Sun Apr 28, 2024 3:54 am I have a big button and I want to find out where it has been clicked in relation to it's top left.
So far I've been positioning it manually, that way I know where my button starts at all times, this limits the use of vbox, hbox, paddings and drags. I wonder is there's an easy way to find where on the button has been clicked, or at least where the button was when it was clicked?
- Kia
- Eileen-Class Veteran
- Posts: 1050
- Joined: Fri Aug 01, 2014 7:49 am
- Deviantart: KiaAzad
- Discord: Kia#6810
- Contact:
Re: get click position on the button?
That's what I've been doing.m_from_space wrote: ↑Sun Apr 28, 2024 4:47 am I guess you could just call a function the moment it is clicked. That function then utilizes renpy.get_mouse_pos() and calculates the rest depending on the position of the button and its size.
But I want to have freedom to place my button in arbitrary positions, utilizing boxes, padding, margin and drags without having to take all of those into account in my calculations.
Re: get click position on the button?
What are you trying to achieve, why do you need such calculations? Maybe a set of overlapping imagebuttons with foces_mask property could do the trick?Kia wrote: ↑Sun Apr 28, 2024 3:54 am I have a big button and I want to find out where it has been clicked in relation to it's top left.
So far I've been positioning it manually, that way I know where my button starts at all times, this limits the use of vbox, hbox, paddings and drags. I wonder is there's an easy way to find where on the button has been clicked, or at least where the button was when it was clicked?
Re: get click position on the button?
Wouldn't renpy.focus_coordinates (https://www.renpy.org/doc/html/other.ht ... oordinates ) be enough to get the info you need?
- Kia
- Eileen-Class Veteran
- Posts: 1050
- Joined: Fri Aug 01, 2014 7:49 am
- Deviantart: KiaAzad
- Discord: Kia#6810
- Contact:
Re: get click position on the button?
When I have something like a chess board, instead of adding a hundred buttons, I usually add one and find out what cell is clicked by doing some math instead.
That's exactly what I've been looking for, thank you ^^philat wrote: ↑Sun Apr 28, 2024 11:00 am Wouldn't renpy.focus_coordinates (https://www.renpy.org/doc/html/other.ht ... oordinates ) be enough to get the info you need?
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot]