1. Robert Sawyer
  2. PowerBuilder
  3. Wednesday, 5 June 2024 21:33 PM UTC

I have PB 22 and have a picture button that I want to change the image when a user hovers over the button. I can map an event (pbm_mousemove) that works fine but, is there an event that tells me when the mouse has moved off of the object? I then want to change the picture to something else when this occurs, but I can't find a corresponding event.

Also, I don't necessarily have to use a picturebutton. Maybe a different object would work too.

Matt Balent Accepted Answer Pending Moderation
  1. Thursday, 6 June 2024 02:07 AM UTC
  2. PowerBuilder
  3. # 1

If it's on a datawindow would this help?  GetObjectAtPointer - - DataWindow Reference (appeon.com)

Comment
  1. Robert Sawyer
  2. Thursday, 6 June 2024 12:15 PM UTC
thank you all for your help!

  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 6 June 2024 02:40 AM UTC
  2. PowerBuilder
  3. # 2

Hi, Robert -

The Windows API function TrackMouseEvent can be used to do this. Earlier this week I suggested to another Community member that had a similar request to yours that they download and examine the DWGridXP free code sample application from Roland Smith's TopWizProgramming web site. One of the feature of this app is it highlights the column header on a grid DataWindow when the mouse is over the column header.

Here is the URL:

    https://www.topwizprogramming.com/freecode_dwgridxp.html

HTH, Best regards, John

Comment
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Thursday, 6 June 2024 07:38 AM UTC
  2. PowerBuilder
  3. # 3

Hi.

You can calculate when the mouse goes out of picturebutton object in pbm_mousmouve. The code should be something like that:

if x > 20 and y > 20 and xpos <= this.width - 20 and ypos <= this.height - 20 then
	picturename = ".\ok.png"
else
	picturename = ".\error.png"
end if

You need to set a threshold (20 in this example), because if you move the mouse pretty fast the event won't fire when "leaving" the picturebutton region. So this isn't perfect!

Andreas.

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 6 June 2024 14:31 PM UTC
  2. PowerBuilder
  3. # 4

Hi Robert;

  FWIW: This is what I do to sense the mouse over an object. The example below is from my STD Framework. You can easily do this by adding a User Event to any visual control where you wish to monitor mouse activity. The implemenation is just map the UE to the O/S's "HitTest" message ID by using PB's "pbm_nchottest" event ID. Then any code you add to this UE will be when the mouse is active over the object, as follows:

Much simpler to use and more future proof.  Food for thought. HTH

Regards .. Chris

 

Comment
  1. Robert Sawyer
  2. Thursday, 6 June 2024 15:08 PM UTC
Does this only cover the mouse over event? I added this event to my picture button and put a messagebox in the code. It worked fine when I hover over the image. The issue I am having is that I need to a mouse 'out' event. There are some UI extenders that when you hover over a command button it changes colors. When you leave the command button "area' the color goes back to it's original color - I don;t know how they do this. That's basically what I'm trying to accomplish but with a picture obect.

Example - p_1.picturename = black, original image, then when I hover over it, change picturename to white, When mouse has moved off, change picturename back to black.
  1. Helpful
  1. Andreas Mykonios
  2. Thursday, 6 June 2024 15:21 PM UTC
Those extenders are wither based on javascript, either they are built on a ui framework like javafx or xaml...

Andreas.
  1. Helpful 1
  1. Chris Pollach @Appeon
  2. Thursday, 6 June 2024 15:36 PM UTC
Hi Robert;

What I do is add the same HitTest UE to the parent Window . When the mouse is detected via the HitTest on the button, your code there would change the picture to the alternate image. I also would register the control via a PowerObject Pointer instance variable on the Parent window. When the Window gets the HitTest UE and sees that its PowerObject instance variable is valid, it then uses that object pointer to send a second UE notice back to that last active control (ie: your picture button) and then it set's the PO pointer back to NULL. Meanwhile, the button receives the 2nd UE and that is the queue to restore the initial image being displayed on the button. This allows for a nice OO approach to your challenge as the CB's behaviour is now totally encapsulated to the button itself. HTH

Regards .. Chris
  1. Helpful 1
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.