PDA

View Full Version : Changing button colours



otuama
04-06-2009, 10:52 AM
Hi All,

Firstly, There are a few (and will probably be a few more) posts by me. I'm new to mel and am working on an assignment. Whenever I make a post asking for some help I'm doing so after tearing my hair out trying to find the answer first.

Ok.....

I have a button (wow, how clever am I :) ). When I press the button I want it to change colour for a short time, maybe .2 of a second to show that it's been clicked.

Can anyone give me a hand with this?

I have tried making 2 buttons, both exactly the same except one is blue and the other another white.

when i click the white button i've told it to hide the white and show the blue then straight away hide the blue and show the white.

But it runs so fast you dont notice it turning blue.

I'm quite good at making ui's but when it comes to the more technical stuff i struggle a lot.

So, if anyone could help I'd be very grateful..

Below is a simple ui for anyone who can give me a hand. Saves you making it youself.

Many thanks,

Otuama

//------------------------------------
//------------------------------------

//When the button is pressed the button changes from white to blue.
//After .2 second it changes back to white.

//White = 1 1 1
//Blue = 0 0 1

if (`window -exists mainWindow`) deleteUI mainWindow;
window
-title "Window"
-width 100
-height 100
mainWindow;

formLayout -numberOfDivisions 100 mainForm;

//Button
button
-label "Button"
-backgroundColor 1 1 1
-command "button()"
windowButton;

//----------------------------------------
//----------------------------------------

formLayout -edit

-attachForm windowButton "top" 50
-attachForm windowButton "left" 50

mainForm;

showWindow mainWindow;

//----------------------------------------
//----------------------------------------

global proc button()
{




}

otuama
04-06-2009, 01:00 PM
Hi, thanks for the reply.

Yeah, basically what it is, is when the user clicks a button it very briefly changes colour.

I thought it would be quite easy. I'm trying to think of a way around it. A loop?

Anyway, if it can't be done it cant be done. thanks for the help anyway