开发者

SWT TabFolder: Weird Drawing Behaviour

开发者 https://www.devze.com 2022-12-23 05:23 出处:网络
Hello StackOverflow Experts Description I have an SWT Page with a TabFolder with a number of dynamically created TabItems.

Hello StackOverflow Experts

Description

I have an SWT Page with a TabFolder with a number of dynamically created TabItems.

On each TabItem i crate a Composite and set the TabItem.setControl() to the Composite. I t开发者_StackOverflow社区hen use this Composite as the page on which i draw my items. I draw a set of Controls, including Textbox's and Labels.

For the First, Default Tab, this works fine. No problems.

Problem

On tabs that is not the first tab i have the following problems:

  • I am unable to visually alter then Edited/Enabled state of my Controls.
  • I am unable to visually set the Text content of my elements

My Controls look disabled and have a Greyed out look.

But i am able to Select the content with my mouse and use CTRL+C to copy it out. So the text contet is there and they are Editable.

Visually it is just not updated.

Any comments are appeciated, Any requests for code, examples will be supplied and help Welcommed.

Updates

I tried added the suggest debug loop to the code, where i attempt to enable my Controls. This was the result:

[main] INFO [dk.viking.controller.LayerController] - f038.stklok is now Editable [true] and enabled [true]

[main] INFO [dk.viking.controller.LayerController] - true Text {}

[main] INFO [dk.viking.controller.LayerController] - true Composite {}

[main] INFO [dk.viking.controller.LayerController] - true TabFolder {}

[main] INFO [dk.viking.controller.LayerController] - true Shell {Viking GUI}


My guess is that the TabItem itself is disabled. I suggest to add a loop in some place of your code which takes a text control and prints it's enable state and then continues with the parent composite and does the same:

 Control c = text;
 while (c != null) {
      System.out.println(c.getEnabled()+" "+c);
      c = c.getParent();
 }

This should give you an idea if this is the cause of your problem. If not, then set a breakpoint in Text.setEditable() and check who calls it.

[EDIT] If the text is editable but not visible (i.e. gray on gray), check what getBackground () and getForeground () return. Maybe someone set both to the same color.


I have found the source of the problem.

The code that used to populate the TabItem's Composite with Controls was being called twice.

So all Controls were duplicated and our Controller only had active references to half of the actually used Controls.

I'm unable to accurately explain the Drawing behaviour we saw, however removing one of these calls caused the problem to go away.

I hope my problems can one day help someone else.

0

精彩评论

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

关注公众号