You can put the text% object directly into the editor-canvas if you want. Also, the 5 pixels is part of the margin I believe and you can set it to 0 if you want. <div><br></div><div>Robby<span></span><br><br>On Friday, July 18, 2014, Dmitry Pavlov <<a href="mailto:dpavlov@ipa.nw.ru">dpavlov@ipa.nw.ru</a>> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I have the need to put a text field into a certain location of a canvas,<br>
without decorations.<br>
What I came up with so far is:<br>
<br>
#lang racket<br>
(require racket/gui)<br>
<br>
(define frame (new frame% (label "Test")))<br>
(define pasteboard (new pasteboard%))<br>
<br>
(define editor-canvas<br>
(new editor-canvas%<br>
(editor pasteboard)<br>
(parent frame)<br>
(style '(no-border no-hscroll no-vscroll))))<br>
<br>
(define t (new text%))<br>
(define ts<br>
(new editor-snip%<br>
(editor t)<br>
(left-margin 0)<br>
(right-margin 0)<br>
(top-margin 0)<br>
(bottom-margin 0)<br>
(with-border? #t)))<br>
(send pasteboard insert ts 0 0)<br>
<br>
(define yellow-delta (send (make-object style-delta%)<br>
set-delta-background (make-object color% "yellow")))<br>
(send t change-style yellow-delta)<br>
(send pasteboard set-caret-owner ts)<br>
<br>
(send frame resize 100 100)<br>
(send frame show #t)<br>
<br>
<br>
Two questions:<br>
<br>
1. Is it the most natural way to do what I need?<br>
(I also looked into embedded-gui but did not find<br>
anything that looks like an embedded text field).<br>
<br>
2. What I see is:<br>
<a href="http://imgur.com/Ws4R140" target="_blank">http://imgur.com/Ws4R140</a><br>
It is obvious that the text is off the (0,0) point where<br>
it should be by about 5 pixels by x and y.<br>
I tried placing it in (-5, -5) and got this:<br>
<a href="http://imgur.com/WrSE1qG" target="_blank">http://imgur.com/WrSE1qG</a><br>
Setting (with-border? #f) did not help.<br>
How can it be fixed?<br>
<br>
Best regards,<br>
<br>
Dmitry<br>
____________________<br>
Racket Users list:<br>
<a href="http://lists.racket-lang.org/users" target="_blank">http://lists.racket-lang.org/users</a><br>
</blockquote></div>