Community
Participate
Working Groups
Build Identifier: 1.5M5 and 1.5M6 I try to create a "Text" object over an "CLabel", in a mode that the Text cover the entire label. With SWT work fine, but with RAP 1.5M5 the "Text" has wrong position, with RAP 1.5M6 give an error. With RAP 1.5M6 the error is: Error: Error: Operation "create" on target "w4" of type "null" failed: c.getChildren() is null Properties: parent = w3 style = LEFT,SINGLE bounds = 6,6,288,38 tabIndex = 2 background = 255,0,0,255 Reproducible: Always Steps to Reproduce: Display display = new Display (); Shell shell = new Shell(display); shell.setSize(600,300); CLabel label = new CLabel(shell, SWT.NONE); label.setBounds(50,50,300,50); label.setBackground( display.getSystemColor(SWT.COLOR_BLUE) ); Text t = new Text(label, SWT.NONE); Rectangle r = label.getClientArea(); t.setBounds( r ); t.setBackground( display.getSystemColor(SWT.COLOR_RED) ); shell.open (); while (!shell.isDisposed ()) { if (!display.readAndDispatch ()) display.sleep (); } display.dispose ();
I got a slightly different error, but the reason is the same - the fix for bug 373765: .. Error: Error: Operation "create" on target "w4" of type "null" failed: Error in property parent of class org.eclipse.rwt.widgets.Text in method setParent with incoming value '[object org.eclipse.rwt.widgets.Label]': Is invalid! .. Before, the client-side Label/CLabel was a qx.ui.basic.Atom which extends qx.ui.core.Parent. After the re-factoring the client-side Label/CLabel now extends org.eclipse.rwt.widgets.MultiCellWidget which is *not* a qx.ui.core.Parent.
Even if it's valid SWT code, CLabel is not designed to host child widgets. I'd recommend that you create the CLabel and the Text widgets with the same parent and set both to the same bounds. The widget you created last will be on top, but you can also use Control#moveAbove() and #moveBelow() to change their z-order. This practice will also work around this JavaScript error.
ok, but this workaround has other problems, for example if the CLabel is in a Composite with a layout, than the layout is wrong. The code, however, is similar for Table and Tree, when a Text is created over a Table for editing an element
(In reply to comment #3) > ok, but this workaround has other problems, for example if the CLabel is in a > Composite with a layout, than the layout is wrong. > > The code, however, is similar for Table and Tree, when a Text is created over a > Table for editing an element In this case, you could create one Composite with a StackLayout that contains the Text and the CLabel, and include this Composite in the parent instead of the CLabel. I really believe that using the CLabel as a Composite is a misuse of the SWT API. You cannot do this with a Label, and CLabel only inherits from Composite because as a custom widget, it has to extend Canvas which in turn inherits from Composite, not because it is meant to host other widgets.