Forums

Find answers, ask questions, and connect with our
community all around the world.

Home Forum Omnis General Coding Creating a drag rectangle on the thick client

  • Creating a drag rectangle on the thick client

    Posted by Paul Mulroney on June 22, 2020 at 3:56 am

    Hi Everyone,
    I’m working on a feature where I want the user to be able to draw a rectangle onto an image on a window in the runtime. At the moment it’s pretty basic – I can track the mouse down and mouse up events, and then it draws the box. However, it would be really cool if the user saw a rectangle as they moved the mouse after clicking mouse down – like drawing a box in a drawing program. For double bonus points it’d be awesome if they could later on select the rectangle and resize it.
    I don’t think there’s any functionality in Omnis that allows us to do that in the runtime. Has anyone done something like this in the past, and are willing to share?
    Regards,
    Paul.
    “Debugging is like being the detective in a crime movie where you’re also the murderer.”

    Paul W. Mulroney We Don’t Do Simple Pty Ltd
    pmulroney@logicaldevelopments.com.au Trading as Logical Developments
    http://www.logicaldevelopments.com.au ACN 161 009 374
    Ph: +61 8 9458 3889 86 Coolgardie Street
    BENTLEY WA 6102

    Paul Mulroney replied 1 year, 5 months ago 1 Member · 1 Reply
  • 1 Reply
  • Paul Mulroney

    Member
    February 17, 2021 at 8:38 am

    OK, so I worked out something that works for us.
    You can create a shape object, with these properties

    • $backpattern: kPatTranparent
    • $bordercolor: something bright eg kYellow
    • $linestyle: something obvious eg Line: 2
    • $shape: kRect3D
    • $effect: kBorderPlain

    In $construct of the window:
    Set reference irBox to $cwind.$objs.objBounds ;; Make this a shortcut to access the shape object
    When we want to enable the shape object, we have a button to enable it with this code:
    Calculate irBox.$selected as kTrue ;; Enable selection handles
    When we save the record, capture the following:

    • irBox.$top
    • irBox.$left
    • irBox.$width
    • irBox.$height

    Don’t forget to disable selection:
    Calculate irBox.$selected as kFalse ;; Disable selection handles
    It’s a little clunky, but it serves our purpose. Maybe others will find this useful!

Log in to reply.