Livecode Drawing Standalone

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, robinmiller, kevinmiller

Post Reply
paul@researchware.com
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 74
Joined: Wed Aug 26, 2009 7:42 pm
Location: Randolph, MA USA
Contact:

Livecode Drawing Standalone

Post by paul@researchware.com » Fri Jun 21, 2019 8:09 pm

I have an old stack (built under LC 4.6.4) that has a component that does some simple drawing. There is a tool bar (some buttons and menus) and below that a drawing area (a scrolling group)

A mouseMove handler sets the tool to the *pointer tool* or the graphics tool (with the applicable type set in the templateGraphic) when over the drawing area and back to the *browse tool* when over the toolbar (so the user could click buttons/menus to perform functions in the toolbar)

In LC4.6.4 when a object was selected in the drawing area (showing selected object handles) and the cursor moved to the toolbar and switched back to the browse tool, the selection handles remained and any selected object was still among the selectedObjects

Now having converted the stack to LC9.0.5, when the cursor is set back to the browse tool, the selection handles on any selected objects disappear and no objects are selected!?

So, how in LC9, does one do the basic task of using LC's built in tools to select objects in a "drawing area" (a group) and keep them selected while mousing outside the drawing area to actually perform some function by clicking and sending a mouseUp event (or menupick or whatever)?

The graphic/drawing tools are not by strong suit in LiveCode. A working sample stack or detailed working sample code would be really helpful so I can understand what the best practice model is for how to do this?
Paul Dupuis
ResearchWare, Inc.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6026
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Livecode Drawing Standalone

Post by dunbarx » Fri Jun 21, 2019 11:31 pm

I implemented a fairly complex drawing module to a stack we use all the time. It isn't CAD, but it looks like it, albeit rather less professional looking than, say, AutoCad or SoldWorks would produce.

We send these drawings out daily to clients. They are based on data calculated within the stack, and use graphic objects galore.

But our drawings are one-way, that is, once drawn, they are complete, and are forwarded as PDF's. You are looking to be able to manipulate objects (in CAD parlance) live on screen. In a CAD environment an object that has been selected remains so, regardless of tool or property changes, until either nothing is selected or one or more (other or additional) objects are explicitly selected.

You are focused on tool switching and control selecting.We can work on that, the goal being that you modify the current behavior of LC to the behavior of the old one you are used to.

I do not need that, since the entirety of my drawing is created under script control.

Something like this in the card script, though I bet it can be made cleaner
and more robust:

Code: Select all

on mouseLeave
  set the liveHandles of this cd to the  name of the target
  select empty
end mouseLeave

on mouseEnter
  do "select" &&  the liveHandles of this cd
end mouseEnter
I would be glad to show you what I make, if that will at least give you an idea of how far you can take drawing in LC. But remember, LC is not a drawing or CAD program. But you can make it act like one. You just have to change some of the built-in rules.

Craig

paul@researchware.com
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 74
Joined: Wed Aug 26, 2009 7:42 pm
Location: Randolph, MA USA
Contact:

Re: Livecode Drawing Standalone

Post by paul@researchware.com » Sat Jun 22, 2019 1:05 pm

I see you example use mouseEnter and mouseLeave. I have noticed that mouseMove, inside of which you can does tests line "if (x,y) is within tDrawingRect then ...", DOES NOT seem to get send when the chosen tool is the Pointer tool.

Is that why you use mouseEnter/mouseLeave? Are there other message constraint I should know about when executing "choose tool pointer" vs "choose tool browse"

OR, the perhaps the first questions is: to move or resize an drawing object, is the "best" approach to choose the pointer tool and let LiveCode do it or is it better to leave the tool as the browse tool and script something for moving (easy) and resizing (not so easy, i.e how do you detect when a user chick on a resize handle of a selected object when in browse mode?)
Paul Dupuis
ResearchWare, Inc.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6026
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Livecode Drawing Standalone

Post by dunbarx » Sat Jun 22, 2019 2:10 pm

Why not just this in the card script:

Code: Select all

on mouseEnter
   if the tool = "browse tool"  and "card" is not in the name of the target then choose pointer tool
   select the target
end mouseEnter

on mouseLeave
   set the cursor to arrow
   choose browse tool
end mouseLeave
This does not care which tool is current. But does this do much of what you need?

Craig

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”