Author Topic: Mouse  (Read 11970 times)

0 Members and 1 Guest are viewing this topic.

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: Mouse
« Reply #15 on: December 05, 2010, 01:25:34 pm »
fix 4 does the opposite of fix 5.

If you use fix 5, you must have fix 4 at the end of your program or else you calc will go bye bye (not die, it just goes funky.)
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Mouse
« Reply #16 on: December 05, 2010, 01:27:17 pm »
fix 4 does the opposite of fix 5.

If you use fix 5, you must have fix 4 at the end of your program or else you calc will go bye bye (not die, it just goes funky.)

Oh thanks much!!! It's now working, even as an Application.

Code: [Select]
To do: Mouse Events

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: Mouse
« Reply #17 on: December 05, 2010, 01:28:56 pm »
need help with mouse events?

Is this anything to do with the secret project?
« Last Edit: December 05, 2010, 01:29:19 pm by happybobjr »
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Mouse
« Reply #18 on: December 05, 2010, 01:33:01 pm »
need help with mouse events?

Is this anything to do with the secret project?


Yes it has :P

So, I have X and Y which are the actual coordenates of the mouse.

However, a button has many coordenates, to check if when I press 2nd a button which size is 8*8 located at 10,10 is pressed:
Code: [Select]
// CODE FOR PICTURE 8*8
Pt-Change(10,10,Pic1
DispGrah
If getKey(54)
If X>=10 and X<=20 and Y>=10 AND Y<=20
ClrDraw
Text(0,0,"You pressed the button")

You think that would work?
« Last Edit: December 05, 2010, 01:33:23 pm by ScoutDavid »

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: Mouse
« Reply #19 on: December 05, 2010, 01:40:49 pm »
i would have to slight for statements. (for statements that the variable is only used for these staements, so that the variable may be used in other for statements).

such that.


If getkey(54)
box(1)
for(a,0,7)
for(b,0,7)
If ((Button top left coordinants + A)=X) and ("" + B = Y)
do event
end
end
end
other button checks.
end
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Mouse
« Reply #20 on: December 05, 2010, 01:50:25 pm »
Code: [Select]
[7E8181818181817E]->Pic1
Pt-Change(10,10,Pic1
If getkey(54)
box(1)
for(a,0,7)
for(b,0,7)
If ((Button top left coordinants + A)=X) and ("" + B = Y)
ClrDraw
Text(0,0,"You pressed the button
Pause 9999
End
End
End
. Other button checks.
End

If ((Button top left coordinants + A)=X) and ("" + B = Y)

Have no idea what this means, what is A? And B? And ""?

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: Mouse
« Reply #21 on: December 05, 2010, 01:52:30 pm »
"" means the y coordinate of the buttin

A and B are empty variables.
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Mouse
« Reply #22 on: December 05, 2010, 01:53:58 pm »
Code: [Select]
[7E8181818181817E]->Pic1
Pt-Change(10,10,Pic1
If getkey(54)
box(1)
for(a,0,7)
for(b,0,7)
If ((10 + A)=X) and ((10 + B) = Y)
ClrDraw
Text(0,0,"You pressed the button
Pause 9999
End
End
End
. Other button checks.
End

From my Axe experience I think there are curly braces somewhere here...

If ((10 + A)=X) and ((10 + B) = Y)

This is what you meant?

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: Mouse
« Reply #23 on: December 05, 2010, 01:55:02 pm »
yes, if your button doesn't ever move.
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Mouse
« Reply #24 on: December 05, 2010, 01:56:33 pm »
Great! It's not a very big code, though. I pretend to have 7 buttons each moment and they will move, but I can handle that

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: Mouse
« Reply #25 on: December 05, 2010, 01:59:44 pm »
the code could be shortened by allot using  > and < tests instead of for statements. I was just making a very genaric code.
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Mouse
« Reply #26 on: December 05, 2010, 02:00:38 pm »
Code: [Select]
// CODE FOR PICTURE 8*8
Pt-Change(10,10,Pic1
DispGrah
If getKey(54)
If X>=10 and X<=20 and Y>=10 AND Y<=20
ClrDraw
Text(0,0,"You pressed the button")

Stuff like that right?

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: Mouse
« Reply #27 on: December 05, 2010, 02:02:27 pm »
20 should be 19.

and there should be parenthesis. around each test statement.
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Mouse
« Reply #28 on: December 05, 2010, 02:28:00 pm »
need help with mouse events?

Is this anything to do with the secret project?


Yes it has :P

So, I have X and Y which are the actual coordenates of the mouse.

However, a button has many coordenates, to check if when I press 2nd a button which size is 8*8 located at 10,10 is pressed:


There's actually a slightly more efficient way of doing it. Let's say that you have a series of buttons arranged vertically, as is common in many GUIs. You could arrange the buttons with a simple algorithm like this:

Code: [Select]
:"WTRSNDMTLSPKOILFIRERS"→Str1
:For(A,0,6
:A*8+5→B
:Text(80,B,3*A+Str1)
:RectI(78,B-1,15,9
:RectI(79,B,13,7
:End

This will display three characters from the string for each button and draw a box around the text. When you go to click on a button, you just have to redo the algorithm with with the Y coordinate.

Basically,
Code: [Select]
:If getKey(54)
:Y-3/8→B
:End

An integer corresponding to the button will now be located in B. The top button on the page will return a 0, the second will return a 1, and so on. This is also easily extended to horizontally arranged buttons.


« Last Edit: December 05, 2010, 02:29:55 pm by Qwerty.55 »
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Mouse
« Reply #29 on: December 05, 2010, 02:30:37 pm »
That's what you are doing in Powder Game, right?

It's a very good way, but truly complicated to get there. Nice brain ya got