Button-handler and drawing

Started by didi, August 01, 2007, 11:13:36 AM

Previous topic - Next topic

didi

Can we draw after the  gs:set-visible command ?


( gs:draw-line 'L1 0 200 200 0 gs:green )
 
 (gs:set-visible 'Mdialog true )
 
 ( gs:draw-line 'L1 50 200 200 200 gs:blue )

 ( define ( ButtonRun-handler )
    ( println  "Button Run" )
    ( gs:draw-line 'L1 0 0 200 200 gs:red )
   ;( gs:set-background 'Mcanvas gs:green )
 )


This is only an example to show the effect .  I can see the green line and even the blue line which is drawn after  the set-visible command .

But i can not see the red line after pressing the run button .



If i minimize the Mdialog-window and then maximize it again i see the red line - or if i set the background after drawing to eg. green ( but not white what is already the background) .

Lutz

#1
Put gs:update after the gs:draw-line command. This will force a repaint of Mcanvas.



Lutz

didi

#2
Thankyou Lutz , it works well.



The next question ,  how can i get rid of all tags ,  is there a  clear-canvas  function ?



I have a clear-button, which should clear the canvas back to white .  

First i've named all lines with the same tag-id , and i use gs:delete-tag,  but  with this i have no possibility to select single lines or tags . Brute force with gs:dispose 'Mcanvas doesn't  work . Or should i generate a list of tags while drawing  to delete them later ?

cormullion

#3
If you name all your tags with slightly varying names, you can presumably delete subsets of them, or all of them, by selecting groups of them first:


(filter (fn (tag) (starts-with (name tag) "I")) (list 'In 'Ih 'Iq 'Id))
;-> (In Ih Iq Id)
; or
(map gs:delete-tag (filter (fn (tag) ....


Haven't tried this yet though...

Lutz

#4
That will work, but I would use strings for the tags and than have it easier filtering with regular expressions etc.



Wherever symbols are used in guiserver you can use strings instead. Symbols are nice because it is one quote less to type and looks better recognizable in syntax highlighted code. But for the kind of operation you want, the string is better.



Lutz

cormullion

#5
I have another question on this topic :-)



How do you access tags? I can see that you can keep a record of the ones that you use, but is there a way of getting the tags that have already been used? Can you obtain a list using some form of wildcard?