At Thu, 2 Mar 2017 11:12:16 +0000, Erich Rast wrote:
> Hi! I have a simple non-editable and non-resizable snip% class that in
> its draw function distinguishes whether it's selected or not. It works
> fine when I select it in a text% with the mouse.
> 
> Now I want to select it in the text% when the user left-clicks on it,
> so I've overridden on-event and tried this:
> 
> (define/public (select-this-snip)
>       (define editor (send (get-admin) get-editor))
>       (define pos (send editor get-snip-position this))
>       (send editor set-position pos (+ pos 1)))
> 
> It *does* select the snip in the sense that a selection background is
> drawn (which is visible on the edges, since the snip itself uses a
> rounded rectangle), but the snip itself is not drawn as highlighted,
> even though I check whether draw-caret is a pair in the draw method. It
> is correctly drawn when I select it manually with the mouse, though.

Use

  (send editor set-caret-owner #f)

to send keyboard focus back to the editor.

When you click a snip that has 'handles-events, then keyboard focus is
moved to the snip instead of to the enclosing editor.

-- 
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].
For more options, visit https://groups.google.com/d/optout.

Reply via email to