Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 257747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:07:23+00:00 2026-05-11T22:07:23+00:00

I’ve written an application recently using SWT. In one of its dialog box, I

  • 0

I’ve written an application recently using SWT. In one of its dialog box, I have a few widgets, one of which is Text, which is designed to support DND with other widgets. I’ve first added DND support for the 2 Tree widgets on the same dialog box (both drag source and drop target). Before I added DND support for that Text widget, I noticed that on Linux platform (gtk), SWT Text widget automatically get drag and drop support. That is, I can already drag from the other Tree widgets and drop on this Text (at any position to inserted there), as well as selecting and dragging any text from this Text to other Tree or Text widget.

However, this is only working on Linux platform but not on Windows. The same program, if running on Windows, will not have any DND support for that Text widget (Tree widgets of course have DND support since I specifically write for them).

So here’s what I want to achieve on Windows as well:

  1. drop text at any position in Text widget.
  2. before dropping and while hovering, able to see the caret position clearly where the intended position to drop. caret position should move along with the mouse cursor.
  3. support multi-line in Text widget

SOLUTION:

DropTarget target = new DropTarget(sytledText, DND.DROP_MOVE | DND.DROP_COPY);
target.setTransfer(new Transfer[] { TextTransfer.getInstance() });
target.addDropListener(new StyleTextDropTargetEffect(sytledText));
  1. Use StyledText instead of Text widget
  2. Use StyledTextDropTargetEffect (or extend it) and add it as dr op listener
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:07:23+00:00Added an answer on May 11, 2026 at 10:07 pm
    1. &
    2. AFAIK in Windows you cannot do that using the Text widget easily. At drop you can insert text at the last cursor position or at the end of the text. You may consider using the StyledText widget which supports dropping at any position and ‘caret hovering’ as well.
    3. Both Text and StyledText support the SWT.MULTI style for being multi-line.

    You can find many great code snippets at the SWT snippets page including examples for drag and drop using the StyledText widget. Also there is a good introduction for DND in SWT.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have thousands of HTML files to process using Groovy/Java and I need to
I have a reasonable size flat file database of text documents mostly saved in
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.