Popupmenu Inserts Text into TextArea

I have a popupmenu above a textarea. When the user changes the popupmenu to anything other than the default value of the popupmenu it inserts a special placeholder tag into the textarea at the point of the cursor. Users use this to construct custom html templates.

The problem with this on the Windows build is that as soon as you select an item on the popupmenu the textarea loses focus thus paste will not work. I have other textareas on main window so I only need the popupmenu to work with that one textarea.

Popupmenu Change Event:

  If Me.Text <> "Choose..." and Window1.Focus = DesignArea then
    
    Dim C as New Clipboard
    C.Text = Me.Text
    DesignArea.Paste
    C.Close
    
  End If

Off hand the only thing I can think of so far would be to make a window property that keeps track of the cursor placement in the editfield each time the user clicks in that editfield and have the popupmenu use that number to insert text into the textarea.

Any better solutions?

[quote=149696:@art ouette]I have a popupmenu above a textarea. When the user changes the popupmenu to anything other than the default value of the popupmenu it inserts a special placeholder tag into the textarea at the point of the cursor. Users use this to construct custom html templates.

The problem with this on the Windows build is that as soon as you select an item on the popupmenu the textarea loses focus thus paste will not work. I have other textareas on main window so I only need the popupmenu to work with that one textarea.

Popupmenu Change Event:

  If Me.Text <> "Choose..." and Window1.Focus = DesignArea then
    
    Dim C as New Clipboard
    C.Text = Me.Text
    DesignArea.Paste
    C.Close
    
  End If

Off hand the only thing I can think of so far would be to make a window property that keeps track of the cursor placement in the editfield each time the user clicks in that editfield and have the popupmenu use that number to insert text into the textarea.

Any better solutions?[/quote]

http://documentation.xojo.com/index.php/TextArea.SetFocus

Use SelText instead of copy/paste.

If Me.Text <> "Choose..." then
   DesignArea.SelText = Me.Text
End If