Highlight Conundrum

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Phil Pendlebury
Automation Wizard
Posts: 538
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Highlight Conundrum

Post by Phil Pendlebury » Tue Jul 19, 2022 12:41 pm

Hi all, here is another puzzle I have been working on.

Using panels as buttons
Using OnMouseEnter/Leave to trigger the subroutines as below with variable per button (there are 112 buttons)
Using "highlight" subroutine to highlight them a specific colour (which also reads their current colour)
Using "unhighlight" subroutine to paint the panel back to the colour I got previously

So like this:

Code: Select all

Let>d=0
While>d<112
  Add>d,1
  AddDialogHandler>Dialog1,Panel%d%,OnMouseDown,MDOWN(%d%) // this is for checking left or right click
  AddDialogHandler>Dialog1,Panel%d%,OnMouseEnter,OHighLight(%d%)
  AddDialogHandler>Dialog1,Panel%d%,OnMouseLeave,OUnHighLight(%d%)
EndWhile

Code: Select all

SRT>OHighLight
  Let>hbutt=%OHighLight_Var_1%
  GetDialogProperty>Dialog1,Panel%hbutt%,Color,buttcol
  SetDialogProperty>Dialog1,Panel%hbutt%,Color,uhcolor
  // MSG>H %hbutt%
END>OHighLight

SRT>OUnHighLight
    Let>uhbutt=%OUnHighLight_Var_1%
    SetDialogProperty>Dialog1,Panel%uhbutt%,Color,buttcol
    // MSG>U %uhbutt%
END>OUnHighLight
This all works fine until the panels are directly next to each other (no gaps) and it is then possible to move the mouse so quickly that the highlighting and unhighlighting gets confused. It will leave some buttons at highlight colour and read the highlight colour as the original colour.

It is not a huge thing but the logic here is beating me.
Phil Pendlebury - Linktree

User avatar
JRL
Automation Wizard
Posts: 3497
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Highlight Conundrum

Post by JRL » Tue Jul 19, 2022 10:24 pm

Try this and let us know.

Create this array somewhere before the dialog opens

Code: Select all

ArrayDim>buttcol,112
Replace your subroutines with these

Code: Select all

SRT>OHighLight
  Let>hbutt=%OHighLight_Var_1%
  Let>value=buttcol_%hbutt%
  If>%value%>/
  Else
    GetDialogProperty>Dialog1,Panel%hbutt%,Color,vButtcol
    Let>buttcol_%hbutt%=vButtcol
  EndIf
  SetDialogProperty>Dialog1,Panel%hbutt%,Color,uhcolor
END>OHighLight
SRT>OUnHighLight
    Let>uhbutt=%OUnHighLight_Var_1%
    SetDialogProperty>Dialog1,Panel%uhbutt%,Color,buttcol_%uhbutt%
END>OUnHighLight

User avatar
Phil Pendlebury
Automation Wizard
Posts: 538
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Re: Highlight Conundrum

Post by Phil Pendlebury » Wed Jul 20, 2022 5:26 am

JRL wrote:
Tue Jul 19, 2022 10:24 pm
Try this and let us know.

Create this array somewhere before the dialog opens

Code: Select all

ArrayDim>buttcol,112
Replace your subroutines with these

Code: Select all

SRT>OHighLight
  Let>hbutt=%OHighLight_Var_1%
  Let>value=buttcol_%hbutt%
  If>%value%>/
  Else
    GetDialogProperty>Dialog1,Panel%hbutt%,Color,vButtcol
    Let>buttcol_%hbutt%=vButtcol
  EndIf
  SetDialogProperty>Dialog1,Panel%hbutt%,Color,uhcolor
END>OHighLight
SRT>OUnHighLight
    Let>uhbutt=%OUnHighLight_Var_1%
    SetDialogProperty>Dialog1,Panel%uhbutt%,Color,buttcol_%uhbutt%
END>OUnHighLight
Ingenious! Thanks for this. :-)
Phil Pendlebury - Linktree

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts