• Welcome to the new COTI server. We've moved the Citizens to a new server. Please let us know in the COTI Website issue forum if you find any problems.
  • We, the systems administration staff, apologize for this unexpected outage of the boards. We have resolved the root cause of the problem and there should be no further disruptions.

Deckplan Canvas

robject

SOC-14 10K
Admin Award
Marquis
So I've got a canvas that's drawing lines and listening for mouse clicks, and I'm working thru the details of some state transitions.

A click stores a point. If there's a previous point, those two are grouped together, essentially. The details there are not important. Mouse movement "carries" the endpoint of the unfinished line segment as well, so you can see how you're stretching the line.

Now I want to turn "off" the recording of points. Unfortunately, I don't think I can listen for both clicks and double-clicks, so I can't use the double-click (I bet I can, but I just don't know how to unsort the two events properly).

So, if the mouse clicks on, say, the toolbar instead of the canvas, then I'll stop recording. If there's a partial segment at the end of the list, I'll delete it.

To add to the fun, I've also got quadratic Bézier curves, which as you may know has an additional control point in addition to the start and endpoints. In curve mode, you're not just drawing lines on a polygon. Still, possibly the best way to roughly lay out a hull shape is to let curves be 'flat' or defaulted, and let the user later drag the control points around as needed.
 
A double click will appear as a click event followed by a separate event, so you need to make the double-click action a natural superset (e.g. Click is select, double click selects and launches) or "undo" the click's action.
 
Not real code, but faux-C++ code
Code:
event{
getEvent(&evt);
if (evt->eventType == click) { clickcount += 1; set timer(doubleclick_time);};
if (evt->eventType == timer) {
switch (clickcount){
    case 2:
        do_doubleclick();
        break;
    case 3:
        do_tripleclick();
    case else: 
        do_singleclick();
        break;
    };
}

Note: some OS's do the listening for double and triple clicks, too; in such cases, they don't pass the initial click until the doubleclick timeout has passed. In such cases, you'll need to add the correct checking.
 
Back
Top