Bug in switch button widget?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 15
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Bug in switch button widget?

Post by SWEdeAndy » Fri Apr 13, 2018 10:45 am

Hi all,

I just noticed something odd with the switch button widget:
The hiliteChanged command is triggered even if the hilite did not change, if you click outside the visible part of the switch button, but within the rect of the widget.

Example:

Code: Select all

on hiliteChanged
   put the hilited of me after msg
end hiliteChanged
If you click within the widget rect, but outside the actual button, it still executes the script, but without the switch flipping.

This causes errors if you only want something to happen if the user actually flips the switch (which is kind of the point with it). Of course, a workaround is to put things like ”if the hilite of me is true then…”. But there are still scenarios when that would not work - try this one for example:

Code: Select all

on hiliteChanged
   if the hilite of me is true then add 1 to fld 1
   else add -1 to fld 1
end hiliteChanged
Poke around the switch button and you get funny results…

Reducing the size of the widget rect doesn’t help, as the visual part then shrinks too, so the margin is constant. And there’s no margin property to set.

I’ve tried this in MacOS 10.13.4, Business 9.0.0 and Indy 8.1.9, both in IDE and standalone, and it’s the same. I haven’t tried in mobile (and touching the narrow area around the button without flipping it would be harder in mobile, so maybe less of a problem there).

I can figure out various scripting solutions to deal with this problem, so I’m not asking for advice on that.
I just wonder if this is a bug and if it’s known?

/Andreas

sphere
Posts: 579
Joined: Sat Sep 27, 2014 10:32 am
Location: the Netherlands

Re: Bug in switch button widget?

Post by sphere » Fri Apr 13, 2018 11:50 am

Just quickly checked.
Indeed it reacts when pushing in the rect but not on the button itself, but it always answers false.

Also strange is, but i did not check and maybe it is the same, if you have a custom button of which the rect is bigger or it has a strnage form not filling the rect. And the part that is not filling is transparent, then the button is also not triggered, but maybe it also gives false. If that is so, then this is the way it works i guess and not a bug.
I always use: if the Hilite of me is true (or false) then blablabla
Sony HitBit HB75P MSX-1, Amiga 500 v1.3, Amiga 600, Amiga 1200, Pentium 1 and onwards to all loose PC crap boards which already was in the Amiga for ages not mentioning the startup speed, which we now have again with SSD :D

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 15
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: Bug in switch button widget?

Post by SWEdeAndy » Fri Apr 13, 2018 12:58 pm

Well, the hilite of me returns "false" if the hilite is false, "true" if it's true.

But a command called hiliteChanged should not execute its code unless the hilite did actually change, in my opinion. So I'd call this a bug. If it's not then I hope someone can explain the logic to me. :?

It's kind of a useless command if I have to script some hilite checking anyway, because the 'Changed' part can't be trusted.

bwmilby
Posts: 116
Joined: Wed Jun 07, 2017 5:37 am
Contact:

Re: Bug in switch button widget?

Post by bwmilby » Fri Apr 13, 2018 10:53 pm

I would suggest making a bug report to Bugzilla. This looks like something I could take a look at fixing next week if nobody beats me to it. Pleas post the report here so I can track it.

sphere
Posts: 579
Joined: Sat Sep 27, 2014 10:32 am
Location: the Netherlands

Re: Bug in switch button widget?

Post by sphere » Sat Apr 14, 2018 10:16 am

SWEdeAndy wrote:
Fri Apr 13, 2018 12:58 pm
Well, the hilite of me returns "false" if the hilite is false, "true" if it's true.
Yes indeed but clicking in the rect but not on the switch itself returns a false, so that part does not seem a bug to me
But a command called hiliteChanged should not execute its code unless the hilite did actually change, in my opinion. So I'd call this a bug. If it's not then I hope someone can explain the logic to me. :?
If this is the case when clicking in the rect but not the switch itself, then i agree. The hilite did not change, the widget only returned false
Sony HitBit HB75P MSX-1, Amiga 500 v1.3, Amiga 600, Amiga 1200, Pentium 1 and onwards to all loose PC crap boards which already was in the Amiga for ages not mentioning the startup speed, which we now have again with SSD :D

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 15
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: Bug in switch button widget?

Post by SWEdeAndy » Sat Apr 14, 2018 11:09 am

Yes indeed but clicking in the rect but not on the switch itself returns a false, so that part does not seem a bug to me
Well, it returns the state of the hilite correctly: if the state of the switch is on, i.e. the hilite is true, then clicking in the rect outside the button returns true (if the script has the line "put the hilite of me").

But the problem, as we seem to agree, is that it shouldn't return anything, since the hilite didn't change.

I'll try to file a bug report - it's a first for me, so I'll try to figure out how to do that... :D

sphere
Posts: 579
Joined: Sat Sep 27, 2014 10:32 am
Location: the Netherlands

Re: Bug in switch button widget?

Post by sphere » Sat Apr 14, 2018 12:21 pm

ah yes you're right.

Let's see what the devs come up with, once you file the bug report.
Sony HitBit HB75P MSX-1, Amiga 500 v1.3, Amiga 600, Amiga 1200, Pentium 1 and onwards to all loose PC crap boards which already was in the Amiga for ages not mentioning the startup speed, which we now have again with SSD :D

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 15
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: Bug in switch button widget?

Post by SWEdeAndy » Sat Apr 14, 2018 5:01 pm


bwmilby
Posts: 116
Joined: Wed Jun 07, 2017 5:37 am
Contact:

Re: Bug in switch button widget?

Post by bwmilby » Mon Apr 16, 2018 3:02 am

PR submitted against develop-9.0
https://github.com/livecode/livecode/pull/6486

sphere
Posts: 579
Joined: Sat Sep 27, 2014 10:32 am
Location: the Netherlands

Re: Bug in switch button widget?

Post by sphere » Mon Apr 16, 2018 12:16 pm

Great! THX
Sony HitBit HB75P MSX-1, Amiga 500 v1.3, Amiga 600, Amiga 1200, Pentium 1 and onwards to all loose PC crap boards which already was in the Amiga for ages not mentioning the startup speed, which we now have again with SSD :D

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 15
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: Bug in switch button widget?

Post by SWEdeAndy » Tue Apr 17, 2018 3:48 pm

Cool, thanks bwmilby! :D

Post Reply

Return to “Talking LiveCode”