Resize/move line graph?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 11
- Joined: Thu Aug 23, 2018 2:14 pm
Resize/move line graph?
Hi all,
For a new project I would like to make it possible for the user to minimize or enlarge a line graph and even drag it to a different location. The panel shows different tables with values and buttons and the idea is that the user may drag the diagram to a place where it's most suitable for his needs. Some of the values or buttons might not be relevant for him and may be hidden by the diagram.
Any ideas how to do this?
Thanks four your help.
For a new project I would like to make it possible for the user to minimize or enlarge a line graph and even drag it to a different location. The panel shows different tables with values and buttons and the idea is that the user may drag the diagram to a place where it's most suitable for his needs. Some of the values or buttons might not be relevant for him and may be hidden by the diagram.
Any ideas how to do this?
Thanks four your help.
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Resize/move line graph?
Try the following (line must be thick enough to enable the user to hit the line).
Script of the graphic:
Script of the graphic:
Code: Select all
on mouseDown
if the topleft of me is not (0,0)
then set the savedRect of me to the rect of me
grab me
end mouseDown
on mouseUp b
if b=3 then -- rightClick
lock screen
if the topleft of me is (0,0) then
set the rect of me to the savedRect of me
else
put the savedRect of me into R
put item 3 of R-item 1 of R into W
put item 4 of R-item 2 of R into H
set the width of me to 32
-- proportional
set the height of me to 32/W*H
set the topleft of me to (0,0)
end if
end if
end mouseUp
shiftLock happens
-
- VIP Livecode Opensource Backer
- Posts: 9669
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Resize/move line graph?
Hi.
Do I assume you are speaking of a line graph widget?
If so, what is the issue? The widget is simple to drag and resize. What Hermann has offered seems suited more to a polygon graphic.
Craig Newman
Do I assume you are speaking of a line graph widget?
If so, what is the issue? The widget is simple to drag and resize. What Hermann has offered seems suited more to a polygon graphic.
Craig Newman
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Resize/move line graph?
Craig.
Yes, you are right, he means that (I overlooked it because the word "widget" is missing).
But there is possibly no simple solution because the line graph widget has no mouse events implemented to use for the LC Script side (the user), I looked into the source code: mouseEvents don't reach the widget, they are all captured by the widget.
I have a solution that uses an overlayed blendLevel 99 graphic and timed messages, but that's not simple ...
Hermann
Yes, you are right, he means that (I overlooked it because the word "widget" is missing).
But there is possibly no simple solution because the line graph widget has no mouse events implemented to use for the LC Script side (the user), I looked into the source code: mouseEvents don't reach the widget, they are all captured by the widget.
I have a solution that uses an overlayed blendLevel 99 graphic and timed messages, but that's not simple ...
Hermann
shiftLock happens
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Resize/move line graph?
Sorry, forgot to give my recipe, here it is, should work with any widget (except those that have a native layer, as the browser widget).
Minimize/Maximize by rightClick, drag by grabbing (mouseDown).
Edit.
Of course you can, instead of changing the rect, simply
- make a rectangle graphic OVER the widget (bring to front)
- set its opaque to true
- set its backColor to white (or whatever, this is the color for the minimized state)
- set the script of the graphic as follows (updated!)
Minimize/Maximize by rightClick, drag by grabbing (mouseDown).
Code: Select all
local LG="line graph"
on mouseDown b
if the topleft of me is not (0,0)
then set the savedRect of me to the rect of widget LG
set the rect of me to the rect of widget LG
set the name of me to LG
if b=3 or the topleft of me is (0,0) then pass mouseDown
put the loc of me into lc
grabMe the mouseH-item 1 of lc,the mouseV-item 2 of lc
end mouseDown
on mouseUp b
if b <> 3 then pass mouseUp
-- for rightClick only
lock screen; lock messages
if the topleft of me is (0,0) then
set the rect of me to the savedRect of me
set the showName of me to false
set the blendLevel of me to 99
else
put the savedRect of me into R
put item 3 of R-item 1 of R into W
put item 4 of R-item 2 of R into H
put 80 into W0 -- or whatever
set the width of me to W0
-- proportional
set the height of me to W0/W*H -- or constant size, say W0/2
set the topleft of me to (0,0)
set the blendLevel of me to 0
set the showName of me to true
end if
set the rect of widget LG to the rect of me
end mouseUp
on grabMe dx,dy
if the mouse is up then exit grabMe
put (the mouseH-dx,the mouseV-dy) into LC
set the loc of widget LG to LC
set the loc of me to LC
send "grabMe dx,dy" to me in 1 tick
end grabMe
Of course you can, instead of changing the rect, simply
- hide the two objects (graphic and widget) and show a button that on click hides itself and shows again the two objects
_OR_ - hide the two objects (graphic and widget), make a snapshot of minimized size of the widget and show this image that on click hides itself and shows again the two objects.
Last edited by [-hh] on Tue Sep 18, 2018 6:32 pm, edited 2 times in total.
shiftLock happens
-
- VIP Livecode Opensource Backer
- Posts: 9669
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Resize/move line graph?
Hermann.
I have never used a widget, but you are right. Messages seem to be blocked in a widget. Even rawKeyDown.
So there is no communication between the LC script and LC builder worlds???
Anyone? Does this seem reasonable? I am not able to determine if the cursor simply enters the widget rect itself? The widget has a script, but that is rather limited in usefulness if no messages can be trapped.
Is it inherent in the nature of widgets?
Craig
I have never used a widget, but you are right. Messages seem to be blocked in a widget. Even rawKeyDown.
So there is no communication between the LC script and LC builder worlds???
Anyone? Does this seem reasonable? I am not able to determine if the cursor simply enters the widget rect itself? The widget has a script, but that is rather limited in usefulness if no messages can be trapped.
Is it inherent in the nature of widgets?
Craig
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Resize/move line graph?
As I use to say: A widget is not an ordinary control ...
But the author of the widget can implement to pass some messages to LC Script. But this is also a question of functionality and performance of the widget.
Handling mouse messages in widgets:
http://forums.livecode.com/viewtopic.ph ... 46#p126346
But the author of the widget can implement to pass some messages to LC Script. But this is also a question of functionality and performance of the widget.
Handling mouse messages in widgets:
http://forums.livecode.com/viewtopic.ph ... 46#p126346
shiftLock happens
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Resize/move line graph?
I wrote a utility that lets you resize or grab and move around ANY widget.
And also hide it by rightClick on the drag-handles.
If hidden you have to select it in the contained menu button.
It is all in that single menu button, just copy it to your stack.
More info:
And also hide it by rightClick on the drag-handles.
If hidden you have to select it in the contained menu button.
It is all in that single menu button, just copy it to your stack.
More info:
- LC 8/9 version
"Sample Stacks" from the LC toolbar or
http://livecodeshare.runrev.com/stack/902 - LC 6/7 version
http://forums.livecode.com/viewtopic.ph ... 26#p171526
shiftLock happens
-
- Posts: 11
- Joined: Thu Aug 23, 2018 2:14 pm
Re: Resize/move line graph?
Thank you so much, Hermann! That's amazing!
-
- Posts: 11
- Joined: Thu Aug 23, 2018 2:14 pm
Re: Resize/move line graph?
There's one question that came up when using the line graph with controls in a standalone:
When I use
## 9,10,11,12: Grab
## __+Cmd- or RightClick: Hide Poly
## __+Shift: Hide Control and Poly
I hide the line graph and/or controls. Is there any simple way of showing them again without restarting the standalone?
Thanks in advance for your ideas.
When I use
## 9,10,11,12: Grab
## __+Cmd- or RightClick: Hide Poly
## __+Shift: Hide Control and Poly
I hide the line graph and/or controls. Is there any simple way of showing them again without restarting the standalone?
Thanks in advance for your ideas.
-
- VIP Livecode Opensource Backer
- Posts: 2262
- Joined: Thu Feb 28, 2013 11:52 pm
- Location: Göttingen, DE
Re: Resize/move line graph?
Sorry, I saw this late. You could use, for example, the escapeKey.
Add to your card's script:
Add to your card's script:
Code: Select all
on escapeKey
do "show " & the label of btn "controlsMenu" --> = the widget
send "mouseUp" to btn "controlsMenu" --> the handles appear
end escapeKey
shiftLock happens