Apache OpenOffice (AOO) Bugzilla – Issue 40890
Button BackgroundColor (and others) not working with native widget look
Last modified: 2017-05-20 11:31:44 UTC
UnoControlButtonModel property BackgroundColor does not seem to be working in SRC680_m69. See Python code below: button = dialogModel.createInstance( "com.sun.star.awt.UnoControlButtonModel") button.PositionX = 4 button.PositionY = 55 button.Width = 45 button.Height = 14 button.Step = Step button.Name = "Test" button.Label = "testagain" button.BackgroundColor = 0x00FF00 Result, button is displayed, but the Background color is not set. I can get and set the Property, but there is no effect in the UI. This used to work.
re-assigning
Adding "regression" keyword as this is a regression from the 1.1.x series
Aidan, I have some problems reproducing this - admittedly with Basic, not Python. If I execute the following script for a dialog model button = oDialogModel.createInstance( "com.sun.star.awt.UnoControlButtonModel") button.PositionX = 4 button.PositionY = 55 button.Width = 45 button.Height = 14 button.Name = "Test" button.Label = "testagain" button.BackgroundColor = 255 * 256 oDialogModel.insertByName( button.Name, button ) then this works perfectly. What I'm missing in your script is an insertion of the button model into the dialog model - did you just omit this, or is this simply not happening? Also, what state is your dialog in? Is it currently being displayed/executed?
The dialog displays fine, the only problem is that the button colors are not being applied. I create the dialog model as follows and insert the button dialogModel = smgr.createInstanceWithContext( \ "com.sun.star.awt.UnoControlDialogModel", ctx ) dialogModel.PositionX = -100 dialogModel.PositionY = -100 dialogModel.Width = (105) dialogModel.Height = (365) dialogModel.Title = "ToolBar" dialogModel.Step = 1 . . //create and modify button . dialogModel.insertByName("my button", button);
which still leaves me clueless about where the dialog is being executed, not to mention that with the current scripts, you only have a dialog model, not a dialog. Can you provide a *full*, reproducible script (plus probably instructions how to use it, since I am not familar with how to use Python in OOo). When trying to reproduce this in Basic, everything works as expected, so either this is a UNO binding problem (which I don't really believe), or a problem of us doing something differently (which I cannot judge, since I still don't know your complete scenario).
Created attachment 21670 [details] ScreenShot of Dialog with one button
Ok, I have reproduced the same problem using Star-Basic. Again, this is using the SRC680_m69 build running on WinXP. Please also see the attached screenshot REM ***** BASIC ***** Sub Main dialogModel = CreateUnoService( "com.sun.star.awt.UnoControlDialogModel" ) dialogModel.Width =300 dialogModel.Height =350 button = dialogModel.createInstance( "com.sun.star.awt.UnoControlButtonModel") button.PositionX = 4 button.PositionY = 55 button.Width = 45 button.Height = 14 button.Name = "Test" button.Label = "testagain" button.BackgroundColor = 255 * 100 dialogModel.insertByName( button.Name, button ) oDlg =CreateUnoService("com.sun.star.awt.UnoControlDialog") oDlg.setModel(dialogModel) oWindow =CreateUnoService("com.sun.star.awt.Toolkit") oDlg.CreatePeer(oWindow, null) oDlg.execute() End Sub
Ah! Your screenshot makes it clear - you are using a native XP theme on your desktop, don't you? Well, in this case all the controls will have the XP look taken from the theme - this is a feature, not a bug. The problem is that you cannot selectively overwrite single aspects of a themed look - most certainly, the would look weird afterwards. The only thing which you probably could do is disabling the native look completely for the dialog as a whole, plus all controls. Unfortunately, this is currently not implemented ...
to be more precise: You can set the "native look" property at a a *peer*, but not at a model. I am also not sure whether setting it at the dialog peer automatically propagates this to child controls. You might want to try adding Dim bNativeLook as Boolean bNativeLook = TRUE oDlg.getPeer().setProperty( "NativeWidgetLook", bNativeLook ) immediately before oDlg.execute()
Setting the NativeWidgetLook to False did the trick, thanks. Is this documented anywhere? Also, it might be better if this did not fail silently, as we have just moved from 1.0 to 2.0 beta, and it seemed as if we lost some of the functionality between releases. thanks again, for the work around.
If it wouldn't fail silently, your script would probably break at this position, which is also not really nice. I think about making the NativeWidgetLook a public property at the dialog model ...
accepting
JA: reset target to 2.0.2 because it is a regression
this is no real regression (see comments above), and not really fixable (dito). => "OOo Later"
IMHO, this belongs to the framework -> changed component.
Reset assigne to the default "issues@openoffice.apache.org".