Topic: Highlighting image button

I have tried to add a highlight effect on image button (when mouse move on the image button) but couldn't.


Is it possible? If so how?

Adam
God... please help me become the person my dog thinks I am.

Re: Highlighting image button

Hello AD1408

You could use two properties for mouse : OnMouseEnter and OnMouseLeave.

With pseudo code, it would be

If Mouse over Button (OnMouseEnter)
   then Form1.Image1.Picture.LoadFromFile('c:\Button2.jpg');    //  Hilighted Button

If Mouse out button (OnMouseLeave)
    then Form1.Image1.Picture.LoadFromFile('c:\Button1.jpg');   //  Normal  Button

JB

Re: Highlighting image button

Hi JB,


Thanks a lot....


I couldn't do it, please see attached sample project.
LoadImage link should be relative, not specific to a location. User may have the application on D, E, etc drive.
Keep in mind JB, you are talking to beginner with one brain cell.

Post's attachments

Attachment icon Image Button.zip 21.14 kb, 408 downloads since 2016-09-26 

Adam
God... please help me become the person my dog thinks I am.

Re: Highlighting image button

Hello Adam, Hello JB,

I've used a couple of different ways in the past to get these sort of effects.  Have a look at the attached project and see if any of them are of use to you.
Basically, the 3 methods are:
1.  change the button caption when the mouse hovers (it's a pity that MVD allows you to change the caption but not the colour)
2.  use a panel as a 'false button' so when the mouse hovers, you can change colour and/or caption
3.  use your own image, overlaid over each other so when the mouse hovers or moves away, the 2 images are toggled.

Hope this helps,
Derek.

Post's attachments

Attachment icon Image Button.zip 371.84 kb, 427 downloads since 2016-09-26 

Re: Highlighting image button

Hello AD1408

Please find in attachment an example for your project (if I understand your expectations)

When in your script you wrote :

/////////////////////// Image button highlight /////////////////
begin
  If Mouse over Button (OnMouseEnter)
     then Form1.Image2.Picture.LoadFromFile('save2.png');    //  Hilighted Button
  If Mouse out button (OnMouseLeave)
     then Form1.Image1.Picture.LoadFromFile('save1.png');   //  Normal  Button
end;

it would never have worked. With Pascal language (used by MVD), all previous instructions must begin with procedures. In this example, by the procedures :

procedure Form1_Image1_OnMouseLeave (Sender: string); and procedure Form1_Image1_OnMouseEnter (Sender: string); and this last
procedure Form1_Image1_OnClick (Sender: string);

You can see that on the same component (here a TImage), we can apply two different actions (changing the image to the passage of the mouse) and one second call form (by clicking on the image).

Does this example answer your question?

JB

Post's attachments

Attachment icon IMAGE BUTTON.zip 24.63 kb, 408 downloads since 2016-09-26 

Re: Highlighting image button

Hi Guys,


Thanks a lot...........
Special thanks to Derek for showing additional methods...


We have show form action.. I added close action to another button, it seems to work, However, with others not so lucky


procedure Form1_Image1_OnClick (Sender: string);
begin
    Form1.New;  //Add new record image on the form1
end;


I tried;
Form1.NewRecord;  and Form1.New;
I get error on compile for both instances. How do we associate image to other button actions such as new record, save, delete, search and so on?

Adam
God... please help me become the person my dog thinks I am.

Re: Highlighting image button

Hello AD1408, Derek

If you use this code :

procedure Form1_Image1_OnClick (Sender: string);
begin
    Form1.New;  //Add new record image on the form1
end;

Nothing will happen (unless you use un script).

You have to place a button behind your image, to hide it and declare as Action NewRecord. (from Objec Inspector).
Please post your project and tell us what you expect with it.

JB

Re: Highlighting image button

Hi Derek and JB,


What I'm trying to do is using images as buttons with image highlight on mouse over. You both guys did the image highlight fine. Thanks again.


I'm stuck on associating image button to actual button action. For instance, when I like to use an image as a button for adding new record, searching, deleting etc. moving mouse over image button creates image highlight and performs the intended action on click. i.e. If I clicked on delete image button, on click it should delete the selected record.


Please see attached Image Button2 sample project.

Post's attachments

Attachment icon Image Button 2.zip 27.83 kb, 381 downloads since 2016-09-26 

Adam
God... please help me become the person my dog thinks I am.

Re: Highlighting image button

Hi Adam, Jean,
Attached is the way I would do it - there are other ways too but I always go for the easy life - LOL!
Have a look at the script - I think it's pretty self-explanatory but give us a shout if something's not clear.
Derek.

Post's attachments

Attachment icon Image Button 2.zip 358.5 kb, 449 downloads since 2016-09-27 

Re: Highlighting image button

Hi Derek,


Thanks a lot... Extra thanks for table grid display info...


I have added more buttons just for exercise.. One issue tho, on run highlight image gets displayed at first, until after moving mouse over image buttons?

Post's attachments

Attachment icon Image Button 3.zip 45.23 kb, 401 downloads since 2016-09-27 

Adam
God... please help me become the person my dog thinks I am.

Re: Highlighting image button

Hi Adam,
The 'visible' object property of each of the highlighted images (add, edit, delete, search etc) needs to be set to 'false' in your form design.
Derek.

Post's attachments

Attachment icon adam1.jpg 140.83 kb, 224 downloads since 2016-09-27 

Re: Highlighting image button

Makes perfect sense... Unfortunately, I failed to see it...


Thanks a lot Derek.....

Adam
God... please help me become the person my dog thinks I am.