I'm currently creating a calc macro with several buttons. It sounds that I faced a very basic issue in changing the button background color. Indeed, I can change the button background color in the dialog editor (general tab of the button properties) but when I run the macro the background color of the button remain gray . It sounds that the new color is applied to the button boudary only or that there's someting in the foreground hiding the change I've done.
Is anybody faced the same problem? is it a known issue ?
I am not able to duplicate your problem. Here are the steps I took in trying to:
* Open Calc
* Ensured View | Toolbars | Form Controls is checked
* Click the "push button" icon in the form controls toolbar
* Place the push button somewhere in the spreadsheet
* Right-click on the push button and select "Control"
* Click the "General" tab
* Select the background color to something other than "Default" (I chose Yellow)
* Close the button control window
* Toggle the design mode off by clicking "Design Mode" in the form controls toolbar
* Clicked the button I created and noticed the color didn't change
* Recorded a simple macro
* Tools | Macro | Record Macro . . .
* Assigned the recorded macro to the button
* Ran the macro and noticed the color still didn't change.
Have you run this on another computer with a different monitor/video card? Maybe your screen resolution is poor.
Have you looked carefully at all the settings in the "General" tab? Maybe one of your settings is causing this to occur (such as a background color in addition to a conflicting graphics image).
If someone posts a fix for your question, then please post a quick thank you and then go to your first post, use the edit button to add [Solved] as the first word of the title so other people can rely on the fix as well.
LibreOffice 3.3.3 on Fedora
May be you are interested in more powerful buttons.
Edit: I just notice that serado69 refers to buttons on a dialog whereas Safway refers to buttons on form and I refer to a replacement for buttons on forms. Sorry, I'll try another answer.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Sub toggleColor(oEv)
REM get model of calling button:
oModel = oEv.Source.getModel()
nColor = oModel.BackgroundColor
if Red(nColor) = 0 then
nNew = RGB(255,0,0)
else
nNew = RGB(0,255,0)
endif
oModel.BackgroundColor = nNew
End Sub
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
I have the same problem as serado69 had in 2008. Almost 4 years have passed but this thread seems to remain unsolved.
I'm afraid those who posted remarks on it may have misunderstood the problem a bit, so let me try to make it more clear.
I have made a dialog in OpenOffice Calc (Tools > Macros > Organize Macros > OpenOffice.org BASIC, then I click on the "Organize" button and in the "Standard" Library I create a new dialog). In the dialog I put buttons, listboxes, numeric fields, textboxes etc. (by choosing their icons in the Toolbar). Then I can change their properties by right clicking on them and choosing "Properties..." In the "General" tab you can change the background colour, as well. The changes seem to take effect as the background colours do change in the dialog editor. However, if you switch off the 'Test mode' by clicking on the "Test mode on/off" button, then the changes disappear. I have the same result if I execute the dialog with a macro like the following:
If I try to change the background colour from the macro, inserting the following line into it, which should change the background colour of the textbox into red, then this is also useless:
I guess it is a bug in OpenOffice Calc. But as I didn't find any other forum topic about it, there may be a solution. Does anyone know about it?
Thanks,
Gabor
Attachments
The window on the left is the editor window, the window on the right is obtained when I switch off the Test mode.
I guess it is a bug in OpenOffice Calc. But as I didn't find any other forum topic about it, there may be a solution. Does anyone know about it?
But my code works with any button you assign to to that code.
Why do you ignore my code?
Why don't you post your code?
Why don't you debug your variables? In particular: What is variable dlgTest outside of sub TestDialog?
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
It really does not work as expected. Tested on both versions of my signature.
Painted only a thin border around the button, but the background is light gray.
Attachments
ToggleBtnColor.PNG (8.34 KiB) Viewed 23476 times
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
I can not even set the color manually. The model colored in design mode but in the loaded dialog the button is grey.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
I may not have a lot to give but what I got I'll give to you...
Apache OpenOffice 4.1.5, LibreOffice 6.4.4.2 (x64) on Windows 7
If you think that I did not answer your question, make allowances for my imperfect English
Thanks for the replies.
Here at work I have OpenSuse 11.4 and LibreOffice 3.3.1. I don't know if regarding this topic there is a difference between LibreOffice and OpenOffice but I think there isn't. In any case, in the evening I will check it at home, too (where I have Ubuntu and OpenOffice, see my signature).
I tried both Villeroy's code and B Marcelly's attached file but neither of them worked for me. I got no error message but the background colour did not change when I clicked on the button. I observed, however, that if I keep moving the mouse over the button (without clicking) then the expected background colour sometimes flashes for a very very short time but then it remains grey again. For me not even the border colour changed.
A simple code that shows my problem is the following:
Sub TestDialog()
Dim dlgTest As Object
DialogLibraries.LoadLibrary("Standard")
dlgTest = CreateUnoDialog(DialogLibraries.Standard.Dialog1)
dlgTest.getControl("TextField1").Model.BackgroundColor = RGB(255, 0, 0)
dlgTest.Execute()
End Sub
Of course, first I need to create a dialog called "Dialog1" in the "Standard" library, which has a textbox called "TextField1". If I run this macro (e.g. by hitting F5 in the macro editor) then the dialog appears, in which the textbox should have a red background but it is grey.
The bug report, shown by JohnSUN-Pensioner seems to be about this topic but I think the problem is not only with buttons but also with textboxes and numeric fields.
Gabor
The bug report, shown by JohnSUN-Pensioner seems to be about this topic but I think the problem is not only with buttons but also with textboxes and numeric fields.
It fails only if the controls belong to a Basic dialog. It works with form controls on a document's draw page.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
I found the solution!
In the bug report, shown by JohnSUN-Pensioner, there is another link to a former bug report (Bug 40890). Reading it I found that you can swith off the "native look" by the following line:
After this line, if you modify the background colour of a button, numeric field or whatever (e.g. dlgTest.getControl("NumericField1").Model.BackgroundColor = RGB(255, 0, 0)), then it will take effect in the dialog after execution.
Best wishes,
Gabor
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
I found the solution!
In the bug report, shown by JohnSUN-Pensioner, there is another link to a former bug report (Bug 40890). Reading it I found that you can swith off the "native look" by the following line:
After this line, if you modify the background colour of a button, numeric field or whatever (e.g. dlgTest.getControl("NumericField1").Model.BackgroundColor = RGB(255, 0, 0)), then it will take effect in the dialog after execution.
Best wishes,
Gabor
This bug is evidently still in existence after 8 YEARS. I was having the same issue with dialog controls. But I did notice one additional thing not mentioned here. You can set the color without the bug fix above if the text field is multi line input is set to Yes in the form designer. But if it is set to No then the background color set either in the form designer or programmatically at runtime, it just won't work without adding the line of code above. I thought after four years since this bug temp fix was introduced that someone ought to speak up and say it's still a problem. Gosh just adding a line to the online docs about this bug would be nice.
I found the solution!
In the bug report, shown by JohnSUN-Pensioner, there is another link to a former bug report (Bug 40890). Reading it I found that you can swith off the "native look" by the following line:
After this line, if you modify the background colour of a button, numeric field or whatever (e.g. dlgTest.getControl("NumericField1").Model.BackgroundColor = RGB(255, 0, 0)), then it will take effect in the dialog after execution.
Best wishes,
Gabor
Million Thanks! This is the solution for my Libre- and OpenOffice-Dialogs in Linux. On Windows the BackgroundColor works right out of the box but in Linux only with this simple line. Thanks!!