MouseOver and changing a Picture bitmap

General help with the Ecere Cross Platform GUI toolkit: Window, common controls, events, etc.
Help with the 2D Graphics library: Surface, Display, Bitmap, Font and others.
Post Reply
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

MouseOver and changing a Picture bitmap

Post by jerome »

This morning nomoon asked on IRC about this. I was lacking sleep and I was under the impression that was indeed broken, but it turned out I was missing a proper path to my mouse over image.

This code works:

Code: Select all

import "ecere"
 
class MouseOverForm : Window
{
   text = "Mouse Over / Picture Test";
   background = activeBorder;
   borderStyle = sizable;
   hasMaximize = true;
   hasMinimize = true;
   hasClose = true;
   size = { 640, 480 };
 
   Picture picture1
   {
      this, image = { "pic1.jpg", transparent = true };
 
      bool OnMouseOver(int x, int y, Modifiers mods)
      {
         Capture();
         image = { "pic2.jpg" };
         return true;
      }
 
      bool OnMouseLeave(Modifiers mods)
      {
         image = { "pic1.jpg" };
         ReleaseCapture();
         return true;
      }
   };
}
 
MouseOverForm form1 {};
Cheers,

Jerome
Post Reply