button highlight question

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
ronniebellie
Posts: 28
Joined: Fri Jun 26, 2015 6:17 pm

button highlight question

Post by ronniebellie » Thu Aug 13, 2015 8:35 pm

I have some buttons on a page that open up a database and runs a MySQL query and displays the array in a data grid. The button highlights for just a moment to a different color upon pushing it (via the object inspector), but I want the button highlight color to remain on until another button on the same page is pushed. How do I get the highlight color to stay on until another button is pushed?

Here's my code for one of the buttons.

on mouseUp
## Connect to the database
put "mysql" into theDBType
put "XXXXXXXXXXXX into theDBHost
put "XXXXXXXXXXXX" into theDBName
put "XXXXXXXXXXXX" into theDBUser
put "XXXXXXXXXXXX" into theDBPassword
put revOpenDatabase( theDBType, theDBHost, theDBName, theDBUser, theDBPassword ) into theConnectionID

if theConnectionID is an integer then
## Query the database for data
put revQueryDatabase( theConnectionID, "SELECT * FROM data WHERE `pres_time` LIKE '%10:15%' AND `accepted` LIKE 'Yes' AND `year` LIKE '2015'") into theCursor

if theCursor is an integer then
ConvertSQLCursorToArray theCursor, theDataGridArray
put the result into theError

if theError is empty then
## The cursor was successfully converted to an array.
## Assign it to the data grid. The 'firstname' and 'lastname' columns
## from the database cursor will appear in the matching columns
## in the data grid.
set the dgData of group "DataGrid 1" to theDataGridArray
end if

## Close the database cursor
revCloseCursor theCursor
end if

## Close the database connection
revCloseDatabase theConnectionID
else
answer "Error connecting to the database:" && theConnectionID & "."
end if
end mouseUp

command ConvertSQLCursorToArray pCursor, @pOutArrayA
local i
local theFields
local theError

## Get the names of all the columns in the database cursor
put revDatabaseColumnNames(pCursor) into theFields
if theFields begins with "revdberr," then
put item 2 to -1 of theFields into theError
end if

if theError is empty then
put 0 into i
## Loop through all rows in cursor
repeat until revQueryIsAtEnd(pCursor)
add 1 to i

## Move all fields in row into next dimension of the array
repeat for each item theField in theFields
put revDatabaseColumnNamed(pCursor, theField) into pOutArrayA[ theField ]
end repeat

revMoveToNextRecord pCursor
end repeat
end if

return theError
end ConvertSQLCursorToArray

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: button highlight question

Post by bn » Thu Aug 13, 2015 8:57 pm

Hi Ronnie,

if you turn off the autoHilite of your button via the properties inspector and add

Code: Select all

set the hilited of me to true
in the mouseUp handler

and add in your second button that should turn off the hilite of button 1

Code: Select all

set the hilited of btn "myFirstButton" to false
it should do the trick

Kind regards
Bernd

ronniebellie
Posts: 28
Joined: Fri Jun 26, 2015 6:17 pm

Re: button highlight question

Post by ronniebellie » Thu Aug 13, 2015 11:45 pm

Thanks. The code "set the hilited of me to true" is working. I have it right after on mouseUp just before the connection to the database. I can see it works because the button pushed becomes gray and stays that way.

But there are 5 buttons on the page, so where in each button do I put the "set the hilited of btn "myFirstButton" to false" code so it turns off the button that is highlighted?

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Re: button highlight question

Post by bn » Thu Aug 13, 2015 11:49 pm

so where in each button do I put the "set the hilited of btn "myFirstButton" to false" code so it turns off the button that is highlighted?
the easiest would be to put it in the mouseUp handler of each button.

Kind regards
Bernd

ronniebellie
Posts: 28
Joined: Fri Jun 26, 2015 6:17 pm

Re: button highlight question

Post by ronniebellie » Fri Aug 14, 2015 4:13 am

All that worked. Thanks for all your help.

Ron

Post Reply