Click not working on no-sprite obj_titles.

M

MrHarlan

Guest
Greetings!

I am trying to create an interactive titles object that detects what room it's in, shows appropriate titles on the screen through a draw text action, changes a variable based on the point_in_rectangle function, and finally on the left mouse pressed event executes a command based on the selection variable.

The left mouse pressed event isn't triggering. If I switch to the enter key pressed event, it works fine.

Does the left mouse pressed event require that the obj has a sprite, and thus it's really detecting click_in_hitbox?

I'm pretty sure I could just move the event into the step event and have an if look at whether the mouse is currently being clicked, but I was using the separate events to reduce clutter. My step event will probably get very bulky as I reuse the object for different rooms.

click event works as an enter key pressed event:
click event.png

step event sets option variable based on mouse position:
step event.png
 
M

MrHarlan

Guest
Thank you for your rapid response. I was afraid that was the issue, but wanted confirmation tomake sure I hadn't created a glitch.
 

ParodyKnaveBob

The Laughing Rogue
Howdy, MrHarlan, and welcome to the GMC! $:^ J

If you intend to check point_in_rectangle anyway, you should probably be able to very simply highlight your event, click the [Change] button (or GMS2 equivalent if you're there), and tell the Left Mouse Button Pressed Event to instead be a Global Left Mouse Button Pressed Event. $:^ J

I hope this helps,
Bob
 
W

Wraithious

Guest
I'm pretty sure I could just move the event into the step event and have an if look at whether the mouse is currently being clicked, but I was using the separate events to reduce clutter. My step event will probably get very bulky as I reuse the object for different rooms.
Yep you'll need to move that into the step event, define the rectangle clicked in, and to avoid clutter you can make a script and have each object that uses it call it with it's own argument value, so in the script you can do different things and put the bulk of your code there divided up into argument values depending on what argument value was given.
 

ParodyKnaveBob

The Laughing Rogue
I'm pretty sure I could just move the event into the step event and have an if look at whether the mouse is currently being clicked, but I was using the separate events to reduce clutter. My step event will probably get very bulky as I reuse the object for different rooms.
Yep you'll need to move that into the step event, define the rectangle clicked in, and to avoid clutter you can make a script and have each object that uses it call it with it's own argument value, so in the script you can do different things and put the bulk of your code there divided up into argument values depending on what argument value was given.
No, seriously, MrHarlan doesn't need to move stuff from his Left Mouse Button Pressed Event to the Step Event. He can continue to use separate events to reduce clutter. I already posted this:

If you intend to check point_in_rectangle anyway, you should probably be able to very simply highlight your event, click the [Change] button (or GMS2 equivalent if you're there), and tell the Left Mouse Button Pressed Event to instead be a Global Left Mouse Button Pressed Event. $:^ J
...but let me clarify in case there's any doubt. I inferred before, but now I'm looking at the screenshots he posted, and yes, he uses (GMS2 and) point_in_rectangle() to determine where the mouse is when the user clicks. When not using the built-in sprite mask functionality, one must use the Global Mouse Events to affect anything. Therefore, since the event (for local mouse interaction) already exists as we see coded, there's no need to even move the code. All one has to do is (~checking the GMS2 manual right now since I still haven't actually used it~) right-click that "Left Pressed" Mouse Event, then select Change Event from the context menu, and finally choose "Global Left Pressed" Mouse Event. Presto, now the object's instance fires that Mouse Event with any click, then checks the aforementioned point_in_rectangle() to see where it matches. (Btw, while looking through the manual, I see there's a new "Tap" Gesture Event alternative, but it might be overkill in this case, I don't know.)

Regards,
Bob
 

Dengar

Member
A cheap workaround. Give the object a sprite and then in the draw event just put a comment. Thatll give u a mask but the sprite wont be drawn.
 
M

MrHarlan

Guest
Thank you both. I was able to solve this problem with the global left mouse pressed event. (If anyone is looking for it in GMS2, it's at the bottom of the list of mouse events, there's a submenu of global mouse events.)

The next issue with this same set of code is that the "Do you really want to quit" dialog pulls the program out of fullscreen, which is visually unappealing. Is there a full-screen friendly version of the dialogue question method that wouldn't include me creating an entire interactive element?
 
Top