PDA

View Full Version : PickPoint and losing focus


TheGrak
11-29-2010, 12:37 AM
I have a script that accepts user input via pickpoint:
-When the user LMB clicks, the fn saves where the user clicked, then calls itself.
-When the user RMB click, the fn calls another fn.
-When the user presses ESC, the fn cancels.

This is all working just fine. The exception is that if the user begins the script, and is in the middle of LMB clicking, but then decides that they want to select the move tool (or any other common task) without first pressing RMB or ESC, the fn breaks. So, I'm referring to that process described as the 'function losing focus'. (Only that fn in the script breaks, other fns work fine.)

When the function loses focus, I think that the fn is still running, awaiting user input in the form of a LMB, RMB, or key press, but for some reason the fn isn't accepting them. I tried to conceptually beat this problem by adding in a default to the case statement described below, but it didn't work.

p = pickpoint()
case of
(
(p == undefined): ...
(p == #escape): ...
(p == #rightClick): ...
(classOf p == Point3): ...
default: ...
)


Questions:
1. What exactly is going on? My guess is probably wrong.
2. Is there a way to 'reset' the fn to a working state? (Besides re-running the script)
3. Can this be handled by a callback/handler/event listener/thingymajig?
4. How would you solve this problem?

TheGrak
12-03-2010, 06:41 PM
Ah, after having banged my head into the wall for a while on this, I don't think there is a solution.
Or rather, the solution would be not to use pickpoint recursively.

Kickflipkid687
12-04-2010, 09:24 PM
You might be able to watch when the user switches to move or what have you, and if the function was still running/they didn't escape or whatever, try calling that function again?

Dennis would definitely have a better idea on all of this though. I think he answered someones question regarding something similar with the user activating move and so forth, but I'm not sure it would be of help in this situation.

Hopefully he replies!

denisT
12-05-2010, 06:21 PM
Ah, after having banged my head into the wall for a while on this, I don't think there is a solution.
Or rather, the solution would be not to use pickpoint recursively.

for me the solution is to use mouseTrack instead of pickPoint:

(
fn mouseTracking msg ir obj faceNum shift ctrl alt =
(
format "%\n" msg

case msg of
(
#mouseAbort: ()
#freeMove: ()
#mousePoint: ()
#mouseMove: ()
)
if msg == #mouseAbort then #abort else #continue
)
act = mouseTrack trackCallback:mouseTracking
format "act: %\n" act
)


it gives me all that I need. Also it gives me ability to check the state of any external variable (or UI control state) to #abort or #continue the tracking.

TheGrak
12-06-2010, 05:10 PM
thanks DenisT! I'll be digesting that code for a while! :)

rodbrew
07-17-2011, 06:01 AM
Hey DenisT,

Is there an easy way to simulate the rubberband function of pickPoint() using your method?

denisT
07-17-2011, 06:10 PM
Hey DenisT,

Is there an easy way to simulate the rubberband function of pickPoint() using your method?


global _points = #()
global _pmouse = undefined
unRegisterRedrawViewsCallback drawRubberband

fn drawRubberband = if _points.count > 0 and _pmouse != undefined do
(
gw.setTransform (matrix3 1)

local points = for p in _points collect (gw.transPoint p)
append points (gw.transPoint _pmouse)

gw.setcolor #line (color 200 200 200)
for k=2 to points.count do gw.wPolyline #(points[k-1], points[k]) off

gw.enlargeUpdateRect #whole
gw.updateScreen()
)
fn mouseTracking msg ir obj faceNum shift ctrl alt =
(
_pmouse = ir.pos
case msg of
(
#mouseAbort: ()
#freeMove: if _points.count > 0 do completeRedraw()
#mousePoint: append _points _pmouse
#mouseMove: if _points.count > 0 do completeRedraw()
)
if msg == #mouseAbort then #abort else #continue
)
_points = #()
registerRedrawViewsCallback drawRubberband
act = mouseTrack trackCallback:mouseTracking snap:#3D
unRegisterRedrawViewsCallback drawRubberband
completeRedraw()
format "act:% numpoints:% points:%\n" act _points.count _points


a fancy line style do yourself ;)

CGTalk Moderation
07-17-2011, 06:10 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.