On Friday, November 20, 2020 at 11:09:13 PM UTC+8 [email protected] 
wrote:

> Thanks, I'm opening another subject meanwhile, Can you please advise? 
>
> This is my current code which displays a rectangle on a pasteboard. 
>
> I'm trying to build a wireframe designer where. I can click on a button or 
> a node on a rectangle to create either an inner rectangle/circle or another 
> standalone shape which will also contains their properties. At the end, 
> those created object will serve to generate code samples. 
>
> Can you please advise what functions or classes needed to improve on that? 
>

To respond to mouse clicks, the snip instance will need to handle mouse 
events, which means you need to (1) set the flag 'handles-events and, 
depending on your use case, 'handles-all-mouse-events and (2) override the 
`on-event` method.

Alex.
 

>
> Below is the current implementation done so far. 
>
>
> #lang racket
> (require racket/gui racket/draw pict)
>
> (define board (new pasteboard%))
> (define toplevel (new frame%
>                       [label "My board"]
>                       [width 500]
>                       [height 500]))
> (define canvas (new editor-canvas%
>                     [parent toplevel]
>                     [editor board]))
> (send toplevel show #t)
> (define my-snip-class
>   (new (class snip-class%
>          (super-new)
>          (send this set-classname "my-snip"))))
> (send (get-the-snip-class-list) add my-snip-class)
> (define rectangle-snip%
>   (class snip%
>     (init-field w h)
>     (super-new)
>     (send this set-snipclass my-snip-class)
>     (define/override (get-extent dc x y width height . other)
>       (when width (set-box! width w))
>       (when height (set-box! height h)))
>     (define/override (draw dc x y . other)
>       (draw-pict (rectangle w h) dc x y))))
>
> (send board insert (new rectangle-snip% [w 30] [h 80]) 100 300)
>
>
>
> On Fri, Nov 20, 2020 at 10:40 AM Alex Harsanyi <[email protected]> 
> wrote:
>
>>
>>
>> On Friday, November 20, 2020 at 4:56:03 PM UTC+8 [email protected] 
>> wrote:
>>
>>> please, can you provide some tutorial about this video? 
>>>    https://www.youtube.com/watch?v=UKMgURA5Wg8
>>>
>>
>> This explains how the program works: 
>> https://alex-hhh.github.io/2020/06/ishido.html, there are other snip% 
>> related tutorials on that web site.
>>  
>>
>>>
>>>
>>> On Fri, Nov 20, 2020 at 5:26 AM Alex Harsanyi <[email protected]> 
>>> wrote:
>>>
>>>> You use snips to build small interactive widgets which can be combined 
>>>> and embedded into other GUI applications.   the snip-class% is a helper 
>>>> class for building snips and editor-snip% is a type of snip which allows 
>>>> building nested editors (an editor within an editor).
>>>>
>>>> DrRacket uses snips for its editor and REPL, and supports user defined 
>>>> snips as well.  For example, in the video below, the plot is a snip% and 
>>>> so 
>>>> is the map.   Once you implement a snip, DrRacket knows how to use it when 
>>>> you show it in the REPL:
>>>>
>>>>     https://www.youtube.com/watch?v=R2KU0ZvIJws
>>>>
>>>> snips can also be embedded into GUI applications, for example you can 
>>>> build a GUI window which contains a map and several plots:
>>>>
>>>>     https://www.youtube.com/watch?v=OElNG3ZGgd0
>>>>
>>>> and you can also build interactive applications.  In the video below, 
>>>> each game tile is a snip% and they are managed by a pasteboard% object:
>>>>
>>>>     https://www.youtube.com/watch?v=UKMgURA5Wg8
>>>>
>>>> Alex.
>>>>
>>>> On Friday, November 20, 2020 at 11:47:19 AM UTC+8 [email protected] 
>>>> wrote:
>>>>
>>>>> I have been reading about those classes but i can't properly figure 
>>>>> out. 
>>>>>
>>>>> what are the main use-case of snip, snip-class and editor-snip? 
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "Racket Users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/racket-users/156fcba7-86b4-483b-a936-8121a0f9f397n%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/racket-users/156fcba7-86b4-483b-a936-8121a0f9f397n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>>
> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/racket-users/c503cbeb-78f7-4296-9678-8247fb98248cn%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/racket-users/c503cbeb-78f7-4296-9678-8247fb98248cn%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/c73ef500-2bc8-48fa-937a-2c7ad0bd24f5n%40googlegroups.com.

Reply via email to