
-----------------------------------
chalcids
Wed May 30, 2012 7:19 am

The right and left click buttons
-----------------------------------
I want to write a morse code program so when i right click a dash appears and when i left click i get a dot and the well the space bar does a space. I want it to type out messages. Is this possible?

-----------------------------------
Raknarg
Wed May 30, 2012 9:44 am

RE:The right and left click buttons
-----------------------------------
You can look into the Mouse module in the documentation.

-----------------------------------
Aange10
Wed May 30, 2012 10:16 am

RE:The right and left click buttons
-----------------------------------
It is indeed very possible.

-----------------------------------
Raknarg
Wed May 30, 2012 12:50 pm

RE:The right and left click buttons
-----------------------------------
actually, just to make it simple:

var mx, my, mb : int

Mouse.Where (mx, my, mb)

When you use this code, the procedure will take in three variable and return the mouse's current status. Respectively the x position, y position relative to the screen, and the current button being pressed (0 for none, 1 for left, 10 for middle wheel and 100 for right, I believe)

-----------------------------------
chalcids
Wed May 30, 2012 12:53 pm

Re: The right and left click buttons
-----------------------------------
but what does have to do with the buttons i want it to when i left click in the program to put a dot on the line on the screen like morse code

-----------------------------------
Tony
Wed May 30, 2012 1:28 pm

Re: The right and left click buttons
-----------------------------------
It has to do with the
i left click
part.

-----------------------------------
chalcids
Wed May 30, 2012 1:47 pm

Re: The right and left click buttons
-----------------------------------
like what is wrong with that part like is there not a button command for that at all

-----------------------------------
Tony
Wed May 30, 2012 2:57 pm

RE:The right and left click buttons
-----------------------------------
That sentence was terrible. Were you trying to ask a question?

-----------------------------------
chalcids
Wed May 30, 2012 3:18 pm

Re: The right and left click buttons
-----------------------------------
i want to know how to use the mouse buttons ie the left click, scroll and right button to do something like when i left click a dot appears when i scroll a space appears and when i right click a - appears.

-----------------------------------
Tony
Wed May 30, 2012 4:20 pm

RE:The right and left click buttons
-----------------------------------
Something like
[code]
loop
   get_click_states
   if ( click_states include left_click) then
      draw_dot
   end if
end loop
[/code]

-----------------------------------
chalcids
Wed May 30, 2012 5:23 pm

Re: The right and left click buttons
-----------------------------------
yeah do you the rest of the code because it says i need to declare some variables?

-----------------------------------
Aange10
Wed May 30, 2012 5:44 pm

Re: The right and left click buttons
-----------------------------------
yeah do you the rest of the code because it says i need to declare some variables?

You need to do the code yourself.

They told you that if you put in three variables to Mouse.Where() that is will respectively output the X,Y, and button states of the mouse.

You were also told that if the button state was 0 then nothing was being pressed, if the state was 1 that it was being left click, if the state was 10 it was being middle clicked, and if the state was 100 it was being right clicked.

So what you've learned:
    - How to get the X position of the mouse.
    - How to get the Y position of the mouse.
    - How to see which button is being pressed.


Now YOU right the code, and if you get stuck we can help. But stuck doesn't mean "Okay I know what i want to do, now tell me how to do everything I don't have."

-----------------------------------
chalcids
Wed May 30, 2012 5:48 pm

Re: The right and left click buttons
-----------------------------------
But why do i need that 
Tony gave me what i wanted i just to know how to declare the variables he used.

-----------------------------------
Tony
Wed May 30, 2012 5:57 pm

RE:The right and left click buttons
-----------------------------------
in case that wasn't obvious, none of what I posted was supposed to be working code; it just resembles code to help you read and inspire ideas for how to approach the problem.

You can't just copy-paste blocks of code together, it will not work. Among other reasons, it's an infinite loop and will never give up control to any of the other code you end up pasting in.

-----------------------------------
Luffy123
Wed May 30, 2012 5:57 pm

Re: The right and left click buttons
-----------------------------------
But why do i need that 
Tony gave me what i wanted i just to know how to declare the variables he used.

He didn't give you anything. Just showed you the format it should be in.

Mouse.Where returns the button that is clicked.

So you should know what you have to do from there. Check what button was clicked and do what you want to do with it.

-----------------------------------
chalcids
Wed May 30, 2012 7:10 pm

Re: The right and left click buttons
-----------------------------------
if i knew how to do that i wouldn't be asking how to do it because there was nothing on what i asked that i learned from that book

-----------------------------------
Raknarg
Wed May 30, 2012 8:10 pm

RE:The right and left click buttons
-----------------------------------
Lets go through it then.

You have a procedure:

Mouse.Where (x, y, b)

This procedure will take in three variables that already exist. Lets do that then.

var x, y, b : int

loop
     Mouse.Where (x, y, b)
end loop


So now we have a short program where we have a loop that returns the x position, y position and the button state of the mouse.

I've already given you plenty of information, if you dont know where to go from this, I don't really know why you're trying to do something this advanced.

-----------------------------------
chalcids
Wed May 30, 2012 8:15 pm

Re: The right and left click buttons
-----------------------------------
you said this tells me where the mouse is. I am don't care where the cursor is i want to click randomly and a . will appear when i left click and when i right click a - appears and doesn't need that advanced stuff would it?

-----------------------------------
Tony
Wed May 30, 2012 8:48 pm

RE:The right and left click buttons
-----------------------------------
right, but you still need to know if that click has occurred or not. That's what "b" in x,y,b is for.

-----------------------------------
Luffy123
Wed May 30, 2012 9:11 pm

Re: The right and left click buttons
-----------------------------------
you said this tells me where the mouse is. I am don't care where the cursor is i want to click randomly and a . will appear when i left click and when i right click a - appears and doesn't need that advanced stuff would it?

You don't have to worry about the variables x, y.

Mouse.Where(x,y,b)

The b is the above method is the button number as in. Right Click, Left Click, Scroll Wheel but the b returns an int value which represents these clicks. So first you have to get the value of b by using this method.

Then check if it's a right click or a left click, and you know how to do this because someone posted in this thread what each click's value is. I don't know the values but you just have to check if b = the click you want's value.

Really I don't think it can get easier then this...

-----------------------------------
chalcids
Thu May 31, 2012 7:30 am

Re: The right and left click buttons
-----------------------------------
okay thanks luffy now i actually understand and thanks to everyone else

-----------------------------------
chalcids
Thu May 31, 2012 7:39 am

Re: The right and left click buttons
-----------------------------------
wait one more issue when i run that code and test the keys the values for my right and left click are both 1 what do i then

-----------------------------------
jr5000pwp
Thu May 31, 2012 7:46 am

Re: The right and left click buttons
-----------------------------------
Somewhere near the top of your code include the line:
[code]Mouse.ButtonChoose ("multibutton")[/code]

This allows turing to distinguish between the 3 mouse clicks.
