Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    New toggleswitch doesn't trigger form click events?

    Hey, i think i have found a bug.

    TextItems, AreaItems, most form components trigger a clickevent when clicked on, so you can add a ClickHandler on the form to do stuff.

    The new 13.1 ToggleItem doesn't trigger those events. Would be great if it did.

    #2
    We've fixed this for tomorrow's builds, dated January 24 and later - you'll be able to catch the click in the form's click or itemChanged handlers.

    Comment


      #3
      Hey, thanks for quick response. Great stuff.

      Comment


        #4
        OK, so i just upgraded to February 6, and i have to say that I'm not noticing a difference.

        If i click inside the square on a textbox, checkbox or other components i get the click, but if i click above the toggleitem i get nothing.

        I add the clickhandler to the form. i.e.:

        Code:
        form.addClickHandler(clickEvent -> {
        //doing stuff            
        });
        EDIT: build number in the console: SmartClient Version: v13.1p_2025-02-05/Pro Deployment (built 2025-02-05)
        Last edited by mathias; 7 Feb 2025, 00:06.

        Comment


          #5
          We're seeing this work as expected, in SmartClient and SmartGWT - in the specific build you mentioned, your Java code shows a popup dialog when you click anywhere on the ToggleItem, if you call SC.say().

          Code:
          form.addClickHandler(clickEvent -> {
              SC.say("clicked");
          });
          You mentioned clicking "above" the item - do you mean actually above it, outside of the visual toggle? That also works for us. If you mean that you have given the actual toggle-child a short height and are clicking outside of the toggle but still inside of the item, please show your code for it.

          Comment


            #6
            Heyhey!

            Here's an example that, for me, behaves as i have explained. If you click on the text item, anywhere, the clickhandler triggers. On the toggleitem though, it only triggers if you don't click exactly on top of the toggleitem itself - i.e. it works on the formitem header or the formitem area around the actual toggle.

            EDIT: i also added a checkboxitem to illustrate the difference - you do get clicks on that one everywhere

            Code:
            public class LoadTheSuperCoolApp implements EntryPoint {
            
                public void onModuleLoad() {
                    SystemConf.getInstance().clearLoadingWindows();
                    Layout main = new Layout();
                    main.setPadding(200);
                    main.setWidth100().setHeight100();
            
                    DynamicForm form = new DynamicForm();
                    TextItem name = new TextItem("name");
                    ToggleItem isSithLord = new ToggleItem("isSithLord");
                    name.setValue("Anakin");
                    isSithLord.setValue(false);
            
                    CheckboxItem hasACoolMask = new CheckboxItem("hasACoolMask");
                    hasACoolMask.setValue(true);
            
                    form.setFields(name, isSithLord, hasACoolMask);
                    form.setCanEdit(false);
                    main.addMember(form);
                    form.addClickHandler(event -> {
                        SC.say("ClicketyClick!");});
            
                    main.draw();
                }
            }
            As a speculation - is it because i call setCanEdit(false) and you don't? Just a guess.
            EDIT: i also added a checkboxitem to illustrate that it works even though the form is not editable.
            Last edited by mathias; 17 Feb 2025, 05:53.

            Comment


              #7
              Yes - if you set a textItem to disabled, it won't fire the form's click-event either.

              Out of interest, why are you catching widget clicks in the form?

              Comment


                #8
                Following up - you're actually correct here, in that canEdit: false (as opposed to being disabled) does not behave correctly for ToggleItem. We'll take a look and get back to you.

                Comment


                  #9
                  We have a slightly different edit/save/cancel flow than you have in your examples. We use canedit to put forms in "edit mode" for users. Drop me an email if you're interested in checking out out app. I'm sure you would find tons of issues :)

                  Comment

                  Working...
                  X