• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM mouse_check_button(mb_right) issue.

A

Alan Régis

Guest
I'm designing a RPG character sheet and right now what i have is a button that opens an image (the sheet itself) with its fields.

I have an object (obj_ficha) with this sprite:

I want to click the little circles in order to fill them, representing the points invested in character creation, so i have done this:

Code:
// In Step Event

if point_in_circle(mouse_x, mouse_y, obj_ficha.x + 142, obj_ficha.y + 130, 8)
{
    if !mouse_check_button(mb_right)
        {
            if mouse_check_button(mb_left)
                {
                    forca = 1;
                }
        }
    else
    {
        forca = 0;
    }    
}
Code:
// In Draw Event

if forca == 1
{
    draw_circle(obj_ficha.x + 142, obj_ficha.y + 130, 8, false);
}
else
{

}
So, right now when i click the first circle, it is filled with black, representing the attribute força (strenght) 1. But when i click with the mouse right button, nothing happens (it should return the attribute força back to 0, erasing the circle...)

It's odd because even when i switch the buttons like this:
Code:
if point_in_circle(mouse_x, mouse_y, obj_ficha.x + 142, obj_ficha.y + 130, 8)
{
    if !mouse_check_button(mb_left)
        {
            if mouse_check_button(mb_right)
                {
                    forca = 1;
                }
        }
    else
    {
        forca = 0;
    }    
}
nothing happens... its like the right button is dead... i dont know what is wrong... can somebody help me, please?
 

Perseus

Not Medusa
Forum Staff
Moderator
Code:
if (mouse_check_button(mb_left)) {
   forca = 1;
}
else if (mouse_check_button(mb_right)) {
   forca = 0;
}
Does that produce the same effect for you? Anyways, try placing a show_message() call before each variable assignment to see if the if statement is actually yielding the desired effect.
 
I

icuurd12b42

Guest
your logic is wrong...
pseudo code:
Code:
if (in_circle_mouse_pos()
{
    if(check_left_mouse())
    {
        //left mouse stuff
    }
    else if(check_right_mouse())
    {
        //right mouse stuff
    }
}
 
A

Alan Régis

Guest
I've already tried that way. Currently the code is like that (same problem: left click fills the circle, right click does nothing):
Code:
if point_in_circle(mouse_x, mouse_y, obj_ficha.x + 142, obj_ficha.y + 130, 8)
{
    if mouse_check_button(mb_left)
        {
            forca = 1;
        }    
    else if mouse_check_button(mb_right)
        {
            forca = 0;
        }
}
I have tried switch as well:

Code:
if point_in_circle(mouse_x, mouse_y, obj_ficha.x + 142, obj_ficha.y + 130, 8)
{
    switch(mouse_button)
        {
            case mb_left : forca = 1; break;
            case mb_right : forca = 0; break;
        }      
}
wich give me the exact same result and problem as the other options... so...any more ideas of what might be the problem?
Ragarnack, can you please give me some more info about the show_message thing?
Anyway, thank you for your help! :)
 

TheouAegis

Member
Put in the Draw GUI Event:

draw_text(0,0,mouse_check_button(mb_right));

See if it is changing to 1.


And your logic in your first code was fine, but it could have been cleaned up:
Code:
if point_in_circle(mouse_x,mouse_y,obj_ficha.x+142,obj_ficha.y+130,8)
{
    if mouse_check_button(mb_right) forca = 0; 
    else if mouse_check_button(mb_left) forca = 1;
}
The order of operations would have the same result. So if that doesn't work, then your right mouse button obviously isn't working.
 
A

Alan Régis

Guest
Put in the Draw GUI Event:

draw_text(0,0,mouse_check_button(mb_right));

See if it is changing to 1.


And your logic in your first code was fine, but it could have been cleaned up:
Code:
if point_in_circle(mouse_x,mouse_y,obj_ficha.x+142,obj_ficha.y+130,8)
{
    if mouse_check_button(mb_right) forca = 0;
    else if mouse_check_button(mb_left) forca = 1;
}
The order of operations would have the same result. So if that doesn't work, then your right mouse button obviously isn't working.
The right mouse button is definitely working as i tested it in and out GameMaker. but for the sake of troubleshooting here's what i have done to test it:

This works:
Code:
// Inside a right click event

show_message("All ok!");
but this does nothing:
Code:
// Inside a step event

if mouse_check_button(mb_right)
{
  show_message("All ok!");
}
So it seems it has something to do with step events not triggering the right mouse button... but still i have no clue of what to do.
 
I

icuurd12b42

Guest
Have not seen this problem since GM6/7, when 2 calls to mouse_check_button_pressed(), the second one would not register. sounds like an issue with your setup. maybe you have some settings in windows that is interfering?
 
A

Alan Régis

Guest
I have no ideia of what setting could be interfering with the right click in game maker... For now i have given up the right click and replaced it for a ctrl click event. At least it works, though not the ideal workaround... Thank you for your help!
 
Top