开发者

Hiding cursor in Text component in Eclipse RCP application

In my eclipse RCP application there are a few buttons & few input boxes & this below Text component. My problem is as soon as I press one of the buttons a cursor starts blinking in the below test component. Can you please let me know how to solve this.

I tried:

  1. setting focus to false for Text.
  2. SWT.READ_ONLY for Text .
  3. Code:

    Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_NO);
    protocolFilterDescription.setCursor(cursor);
    

Nothing seems to get rid of this unnecessary cursor.

protocolFilterDescription = new Text(parent, SWT.NONE | SWT.READ_ONLY  );
FormData protocolFilterDescription开发者_开发知识库LData = new FormData();
protocolFilterDescriptionLData.left = new FormAttachment(0, 1000, 650);
protocolFilterDescriptionLData.top = new FormAttachment(0, 1000, 290);
protocolFilterDescriptionLData.width = 450;
protocolFilterDescriptionLData.height = 12;
protocolFilterDescription.setLayoutData(protocolFilterDescriptionLData);
protocolFilterDescription.setForeground(new Color(parent.getDisplay(),
  204, 153, 0));
protocolFilterDescription.setBackground(Display.getCurrent()
  .getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
protocolFilterDescription.setFont(new Font(parent.getDisplay(),"Verdana",
  6, 1));
protocolFilterDescription
  .setText("captured");


You have to set the focus of some other SWT component to true to remove the focus from the Text component.

You'll probably have to do this in an ActionListener.


If you want to completely remove the cursor from the Text control (which implies inability to perform a selection there, etc), try calling setEnabled(false) on it.

Also, such requirement suggests that you maybe don't need Text component at all, and could use Label instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜