Skip to content

fix typo in jig #511

@CEXT-Dan

Description

@CEXT-Dan

Discussed in #510

Originally posted by gswifort May 14, 2026
I observed the following behavior when using Ed.DrawJig. @CEXT-Dan — could you confirm whether these are intended?

Observations:

  1. jig.drag() usually returns the same status returned by sampler(), with exceptions:
    If the user presses Esc: sampler() runs to completion, but drag() returns kCancel regardless; update() and worldDraw() are not called.
    If sampler() returns kNoChangedrag() still returns eOk.
    Behavior by sampler() status:
    eOkupdate() and worldDraw() are called (normal).
    kCancel → jig ends immediately.
    kNull → jig runs; worldDraw() and update() are called (effectively same as eOk).
    kOther → mouse movement does not call update()/worldDraw(); zoom calls update() and worldDraw(); panning calls only worldDraw() (not update()); zoom while panning behaves like panning.
    kModeless → behaves like kCancel.

  2. After clicking a point or pressing Enter, depending on what we return from sampler() we can distinguish the following end cases for the Jig:
    eOk → after sampler() update() is called but not worldDraw(),
    kNull → after sampler() neither update() nor worldDraw() is called,
    kOther → same as eOk, i.e. after sampler() update() is called but not worldDraw().

  3. If update() returns False, then drag() returns kOther (note, update() must be called, so for example, this won't happen when kNull is returned from sampler()); returning False from update() has no effect on Jig's behavior when moving the mouse around the screen.

  4. If worldDraw() returns False, then Jig terminates immediately and drag() returns kCancel

Repro code:

def test_jig():

    class MyJig(Ed.DrawJig):
        def __init__(self):
            super().__init__()
            self._line = Db.Line()

        def sampler(self) -> Ed.DragStatus:
            self.setUserInputControls(Ed.UserInputControls.kNullResponseAccepted)
            status, point = self.acquirePoint()
            self.point = point
            print("sampler", status, point)
            return status
            # return Ed.DragStatus.eOk
            # return Ed.DragStatus.kCancel
            # return Ed.DragStatus.kNull
            # return Ed.DragStatus.kOther
            # return Ed.DragStatus.kModeless
            # return Ed.DragStatus.kNoChange

        def update(self) -> bool:
            print("update")
            self._line.setEndPoint(self.point)
            return True
            # return False

        def worldDraw(self, wd: Gi.WorldDraw):
            print("worldDraw")
            geom = wd.geometry()
            geom.draw(self._line)
            return True
            # return False

    jig = MyJig()
    jig.setDispPrompt("Click a point or press Enter: ")
    status = jig.drag()
    print("Jig finished with status:", status)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions