Results 1 to 3 of 3

Thread: Obtaining the Cursor Position

  1. #1

    Default Obtaining the Cursor Position

    How can I obtain the cursor position? I'm working on a title screen and I'd like to make the graphical buttons clickable.


    Kind Regards,
    Haku

  2. #2
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    There are 2 ways:
    Code:
    	CL_Slot slot_mouse_down = (window.get_ic().get_mouse()).sig_key_down().connect(this, &App::on_mouse_down);
    
    	....
    
    	while(main_loop)
    	{
    	....
    
    	}
    
    
    void App::on_mouse_down(const CL_InputEvent &key, const CL_InputState &state)
    {
    	const char *str="Unknown";
    	switch (key.id)
    	{
    		case CL_MOUSE_LEFT:
    			str="Left";
    			break;
    		case CL_MOUSE_RIGHT:
    			str="Right";
    			break;
    		case CL_MOUSE_MIDDLE:
    			str="Middle";
    			break;
    		case CL_MOUSE_WHEEL_UP:
    			str="Up";
    			break;
    		case CL_MOUSE_WHEEL_DOWN:
    			str="Down";
    			break;
    		case CL_MOUSE_XBUTTON1:
    			str="Button 1";
    			break;
    		case CL_MOUSE_XBUTTON2:
    			str="Button 2";
    			break;
    		default:
    			break;
    	}
    	...etc
    
    	xpos = key.mouse_pos.x;
    	ypos = key.mouse_pos.y;
    
    }
    or
    Code:
    	CL_InputDevice &mouse = window.get_ic().get_mouse();
    
    	left = mouse.get_keycode(CL_MOUSE_LEFT);
    	middle = mouse.get_keycode(CL_MOUSE_MIDDLE);
    	right = mouse.get_keycode(CL_MOUSE_RIGHT);
    
    	CL_Point position = mouse.get_position();
    The above examples are from Examples/Input/Input

  3. #3

    Default

    Thank you for the help. That's what I needed to know.

    Kind Regards,
    Haku

Similar Threads

  1. X11 Cursor
    By spin in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 08-22-2011, 02:02 PM
  2. Replies: 0
    Last Post: 01-23-2011, 04:45 AM
  3. Cursor and Sprite question.
    By Eng C. Born in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 04-18-2009, 02:05 PM
  4. CL_Sprite mouse cursor
    By AlfaRed in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 02-11-2009, 09:29 AM
  5. resolution, mouse cursor, etc
    By Uhfgood in forum Novashell Game Creation System
    Replies: 1
    Last Post: 09-06-2007, 12:40 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •