Debugging: Counter adds 2 instead of 1, string width not updating

advanced-prototyping
newbie-question

#1

Hi, I need some help debugging the following two issues:

  1. I have set up a counter that adds/subtracts 1 in order to count the number of selections made. It sometimes adds/subtracts 2 and I can’t identify the case.
    To reproduce simply try clicking on the checkbox. There are some combinations of clicking clear all/done that adds/subtracts 1 but this isn’t always the case.
    Note: the actions need to stay on the group and not moved to the checkbox widget please.

  2. The size of the dropdown should change dynamically. If the user has made a selection it should reflected “## selected” and resized to fit that + an ‘x’ appears. If the user clears/unselects the selection it should default back to “Input placeholder” and resized to fit that.
    I previously had this set up to resize with a fixed number based on the known width of “## selected” however I’d like to make it more dynamic to allow more flexibility with the string used for reflection.

Any help identifying the issues and/or potential solutions would be much appreciated.

Referenced file:
Filters_Filter-Dropdown.rp (72.1 KB)


#2

Hi!

What you’ve encountered is a bug that has existed for over a year and is still unfixed. There isn’t a general workaround for this. (The workaround provided by support in this thread is specific to that use case.)

If you are planning to have multiple checkboxes and count the number of checkboxes clicked, you can reliably use a repeater to contain the checkboxes and come up with a correct sum of those selected. I will provide a sample below. If the sample doesn’t make sense, try looking over this article, which goes into detail how the repeater works.

I couldn’t quite follow what you are trying to do in your second item.

checkbox_count_in_repeater.rp (50.4 KB)


#3

Hi, that’s strange. I have the exact same set up in another file just that the counter is set on the checkbox instead of the group and it works perfectly fine. Is the bug simply on grouped elements?

This is an example of the counter working in another file, hence why I can not understand the reason its not working in the previously attached file. WorkingCounter-Example.rp (68.6 KB)


#4

Hi!

Good catch. Your diagnosis turns out to be correct, though I can’t explain exactly what is going on.

Observation 1: if I copy the On Clicked code out of the group, place a hotspot over everything, and then paste the code into the hotspot, everything behaves as expected. (+1, -1)

Observation 2: If I copy the On Clicked code out of the group, ungroup everything, contain everything in a dynamic panel, and put the On Clicked code on the panel, the same undesired +2 behavior happens.

Observation 3: on both the grouped situation and the dynamic panel situation, if I click on something that is not the checkbox—e.g., the rectangle behind it or border line—then I get the expected +1 behavior.

So it seems that somehow the checkbox, when both directly clicked and toggled through code in its container, is generating an extra Clicked event on the container. In the example that works that you provided, the code is in the checkbox itself rather than the thing containing the checkbox.

So if you are using the group to make a larger (than the checkbox) click target, use a hotspot instead. Otherwise, get rid of the OnClicked code and just rely on the Selected/Unselected events of the checkbox.


#5

Hi, so I’ve managed to set up the file with the hotspot. One question here, is there a way to add mouseover states with a hotspot? I know you can not trigger anything from the hotspot but do you have a workaround suggestion?

Going back to the original post I’m still facing some issues here:

Basically in the following file:
Filters_Filter-Dropdown-2.rp (77.3 KB)

I now have the dropdown set up with the repeater list and hotspot. I’ve transferred all the commands from the previous group to the hotspot. I want that

When a checkbox (Filter-value_Label) is selected,
the textfield (Filter_Input) shows “# selected”
the panel state (Filter_Dropdown-ICON) updates to cross
the dropdown background (Filter_BG) resizes to accommodate the string (# selected) + icon

THEN

When all checkboxs (Filter-value_Label) are false,
the textfield (Filter_Input) shows “Input Placeholder”
the panel state (Filter_Dropdown-ICON) updates to chevron
the dropdown background (Filter_BG) resizes to accommodate the string (Input Placeholder) + icon

Here is the issue;
If you select the 1st and 2nd checkbox the counter updates and thats it
If you select the 3rd checkbox it almost fully works (only the resizing isn’t working).

  1. Why is it only working for the 3rd checkbox?
  2. Why isn’t the BG resizing / icon repositioning either

#6

Hi!

I think you are better off using the hotspot with your original approach rather than the approach of putting the checkboxes in a repeater. The hotspot will resolve the problem you started out with. If you group the the other items that you want to react on mouseover, that will resolve your mouseover issue.