Shape fill color on/off click

Discuss the spreadsheet application
Post Reply
coolguyhb
Posts: 6
Joined: Tue Sep 11, 2018 9:38 pm

Shape fill color on/off click

Post by coolguyhb »

I have several shapes that i am using as buttons using macros. What i am looking to do is change the color of the button when the button is selected. I have seem to have accomplished changing the color of the button on click, however if i click that same button again it changes back to the default color i originally set it to. I need this button to change back to the default color only after i click another button. These buttons control information in a cell. So the issue with clicking a button then clicking the same button again and its color changing is that the the information in the cell no longer shows that it corresponds with that selected button.

The following code pertains to one button and its action

Code: Select all

sub Product_Info
rem ----------------------------------------------------------------------
rem define variables
dim document   as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document   = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "1Information.D6"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())

rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "StringName"
args2(0).Value = "=2Data.C1"

dispatcher.executeDispatch(document, ".uno:EnterString", "", 0, args2())

rem ----------------------------------------------------------------------
Dim oDoc As Object
Dim Page As Object
Dim RectangleShape As Object
oDoc = thisComponent
page = oDoc.drawPages(0)
RectangleShape = oDoc.createInstance("com.sun.star.drawing.RectangleShape")
nNumShapes  =  Page.getCount()
For i = 1 To nNumShapes - 10
RectangleShape = Page.getByIndex(i)
if RectangleShape.LayerName <ProductInfo> "i" then
goto nextShape
end if
if RectangleShape.FillColor = RGB (114, 159, 207) then
RectangleShape.FillColor = RGB (61, 174, 233)
else
RectangleShape.FillColor = RGB (114, 159, 207)
end if
nextShape:
next i

end sub
Harley
LibreOffice Version: 5.3.6.1
OS: CentOS Linux 7
User avatar
Zizi64
Volunteer
Posts: 11358
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Shape fill color on/off click

Post by Zizi64 »

What i am looking to do is change the color of the button when the button is selected. I have seem to have accomplished changing the color of the button on click, however if i click that same button again it changes back to the default color i originally set it to. I need this button to change back to the default color only after i click another button.
The Radiobuttons are not appropriate for you? You can find it on the Form control toolbar.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
coolguyhb
Posts: 6
Joined: Tue Sep 11, 2018 9:38 pm

Re: Shape fill color on/off click

Post by coolguyhb »

Radiobuttons wouldn't conform to the GUI i have setup. Radiobuttons would have been easier but after applying them, the GUI looked more like a form and not like a program which i am going for.
Harley
LibreOffice Version: 5.3.6.1
OS: CentOS Linux 7
Post Reply