View topic - Get mouse position/Get mouse control



All times are UTC + 1 hour


Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: 24 Mar 2012, 12:40 
Moderator

Joined: 05 Aug 2009, 19:42
What I want: Be able to read current mouse position in one of my drawing functions (called from DrawWorld).
Now, I'm only supposed to be drawing that if my widget is in a certain state, but that state is triggered by pressing on a chili button, therefor I cannot do a "return true" in MousePress to get mouse control, because it never gets called.

So I'm looking for a way to either get current mouse positions in an arbitrary function (that isn't a Mouse* call-in) or for a way to gain mouse control from an arbitrary function so my MouseDraw would be called.

Sample of what I want to do:

Code:
function widget:DrawWorld()
  if internalState == "drawUnit" then
    -- not even sure if this is a way to draw a unit, but whatevs
    gl.PushMatrix()
    -- these unitDraw_* variables should be either set in a MouseDraw or fetched by some unsynced read...
    gl.Translate(unitDraw_x, unitDraw_y, unitDraw_z)
    gl.UnitShape(selUnitDef, teamId)
    gl.PopMatrix()
  end
end

-- and somewhere I have a chili button
function widget:initialize()
  window = Chili.Window:New {
     parent = screen0,
     children = {
        Chili.Button:New {
           caption = "clicky",
           OnClick = {
             function()
               internalState = "drawUnit"
             end
           }
        }
     }
  }
end


Top
 Offline Profile  
 
PostPosted: 24 Mar 2012, 12:55 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
Spring.GetMouseState
http://springrts.com/wiki/Lua_UnsyncedRead#Mouse_States
:?:


Top
 Online Profile  
 
PostPosted: 24 Mar 2012, 13:07 
Moderator

Joined: 05 Aug 2009, 19:42
:oops:


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.