Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

getting mouse coordinates

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-28-2009, 02:35 PM
enonod's Avatar
Basic4ppc Veteran
 
Join Date: Oct 2007
Location: U.K.
Posts: 324
Default getting mouse coordinates

I seem to be having a lot of trouble finding how to get mouse coordinates when clicking on, for example, an image or a gamewindow. It feels as if my brain has turned off.
Any pointers please?
__________________
You never stop learning until you die.
Sometimes I think I am dead.
Sometimes others think I am dead!
Homesite: http://www.don-simmonds.co.uk for Libyan Mural

Device:Viewsonic VPad7, Android 2.2.2
Reply With Quote
  #2 (permalink)  
Old 06-28-2009, 04:33 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

In a GameWindow read the X and Y properties in the CollisionMouse and NoCollisionMouse events.

In an Image you can add a MouseDown event with the Door library.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #3 (permalink)  
Old 06-28-2009, 05:45 PM
enonod's Avatar
Basic4ppc Veteran
 
Join Date: Oct 2007
Location: U.K.
Posts: 324
Default

I am grateful agraham, I don't know what I would do without you.
I am not familiar with using the libraries but I am sure it will go smoothly.
It did not occur to me that the mouse might be 'colliding' with the window.

[Edit]Ammend that, external libraries. I see that Door is an internal, what a peculiar name? Must be access to something, which I am sure will become clear.
__________________
You never stop learning until you die.
Sometimes I think I am dead.
Sometimes others think I am dead!
Homesite: http://www.don-simmonds.co.uk for Libyan Mural

Device:Viewsonic VPad7, Android 2.2.2

Last edited by enonod : 06-28-2009 at 05:48 PM.
Reply With Quote
  #4 (permalink)  
Old 06-28-2009, 06:08 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,726
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

The Door library allows you to access .Net Framework features without creating a custom library. The downside of this library is that it requires some knowledge of the .Net Framework.
Here is the code that catches the MouseDown event of an Image control:
Code:
Sub Globals
    
'Declare the global variables here.

End Sub

Sub App_Start
    Form1.Show
    obj.New1(
False)
    obj.FromControl(
"image1")
    MouseDownEvent.New1(obj.Value, 
"MouseDown")
End Sub

Sub MouseDownEvent_NewEvent
    obj.Value = MouseDownEvent.Data
    x = obj.GetProperty(
"X")
    y = obj.GetProperty(
"Y")
    form1.Text = x & 
" " & y
End Sub
The source code is also attached as a file.
Attached Files
File Type: sbp 1.sbp (788 Bytes, 26 views)
Reply With Quote
  #5 (permalink)  
Old 06-28-2009, 06:16 PM
enonod's Avatar
Basic4ppc Veteran
 
Join Date: Oct 2007
Location: U.K.
Posts: 324
Default

Thank you for that Erel. In fact I made a mistake, the background image I am using in the game window is actually a sprite. When I click on the image (sprite) I do not trigger the event (collisionmouse), however if I click on a sprite passing over the background sprite I do trigger it.
I would appreciate knowing if there is something different if a sprite is used for a background.
Thank you.
[Edit] I don't think I would have got there without your code, I simply started using gw.X etc.
__________________
You never stop learning until you die.
Sometimes I think I am dead.
Sometimes others think I am dead!
Homesite: http://www.don-simmonds.co.uk for Libyan Mural

Device:Viewsonic VPad7, Android 2.2.2

Last edited by enonod : 06-28-2009 at 06:30 PM.
Reply With Quote
  #6 (permalink)  
Old 06-28-2009, 06:31 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Don't confuse an Image (Bitmap) with an Image control. In this case I don't think you have an Image control so the Door library won't work.

If the image is actually a Sprite then clicking on it should raise a CollisionMouseEvent and you can get the coordinates from the X and Y GameWindow properties. You can use the new ID property in the 1.21 version of the Sprite library I just posted. to identify the individual Sprite returned by the Sprite1 property.

EDIT:- How are you using a Sprite as a background?
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #7 (permalink)  
Old 06-28-2009, 06:53 PM
enonod's Avatar
Basic4ppc Veteran
 
Join Date: Oct 2007
Location: U.K.
Posts: 324
Default

I think I have been at it too long today, I have had many experimental versions while experimenting and got out of sync.
In fact I used an Image on a GameWindow...
Code:
gw.New1("Form1",0,0,321,321)
    gw.DrawBackgroundImage(AppPath & 
"\grid 20x20.png")
(Almost a sprite?)

I have sprites on the image and the CollisionMouse suggested by you works with them. It does not work with the BackGround Image and doesn't work with Door.
I guess I have dropped between the two, or... am I clicking on the window.
__________________
You never stop learning until you die.
Sometimes I think I am dead.
Sometimes others think I am dead!
Homesite: http://www.don-simmonds.co.uk for Libyan Mural

Device:Viewsonic VPad7, Android 2.2.2
Reply With Quote
  #8 (permalink)  
Old 06-28-2009, 07:01 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

That's not an Image control nor a Sprite, you are merely using an image file as a background. As it looks like a small image I would imagine it is being stretched to fit the GameWindow. Clicking on the GameWindow background should raise the unfortunately named NoCollisionMouse event.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
  #9 (permalink)  
Old 06-28-2009, 07:10 PM
enonod's Avatar
Basic4ppc Veteran
 
Join Date: Oct 2007
Location: U.K.
Posts: 324
Default

The gamewindow is the same size as the image, it is a windowed screen. [Edit] Now I see why you thought it was small it is 20x20 but each is 15 pixels.
Thank you, you have guided me to the oddly named event which does work.

Code:
Sub gw_NoCollisionMouse
Msgbox("yes")
    label3.Text=gw.x
    label4.Text=gw.y
End Sub
Thanks, now to look at your new Sprite library which I presume I just drop into Libraries folder.
__________________
You never stop learning until you die.
Sometimes I think I am dead.
Sometimes others think I am dead!
Homesite: http://www.don-simmonds.co.uk for Libyan Mural

Device:Viewsonic VPad7, Android 2.2.2

Last edited by enonod : 06-28-2009 at 07:13 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mouse OutSide A Form eww245 Questions (Windows Mobile) 9 07-15-2009 06:27 AM
GPS Coordinates / City names JesseW Chit Chat 6 03-26-2009 12:19 AM
Plot Coordinates ceaser Basic4ppc Wishlist 3 11-16-2008 06:11 PM
Context Menu X,Y coordinates evaklim Questions (Windows Mobile) 1 10-16-2007 01:04 PM
X,Y coordinates Cableguy Code Samples & Tips 0 05-24-2007 07:00 PM


All times are GMT. The time now is 04:34 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0