Trigger Button on Mobile

  • Julia
        5 years ago #18002

        Hello!

        How is it possible to trigger a button on my mobile (IOS) in Simplifier app?
        It works fine with ‘click();’ event in preview mode on PC, but I can’t make it work on a mobile device.

        Thanks for your help!

        Julia

        jonas.rausch
            Has successfully completed the online course Introduction
            Has successfully completed the online course Intermediate (200)
            Has successfully completed the online course Advanced (300)
          5 years ago #18024
          Up
          1
          Down
          ::

          Hello Julia,

           

          The jQuery .click() event only works with a mouse.

          If you want to have a mobile ready event, you can use the “touchstart” or “touchfinish” events.

           

          But you can also use the .press() event of the UI5 button.

          This can easily be done in the process designer of you Simplifier Application.

           

          Dinkel
              Has successfully completed the online course Introduction
              Has successfully completed the online course Intermediate (200)
              Has successfully completed the online course Advanced (300)
              Has successfully completed the online course Basics (100)
            5 years ago #18379
            Up
            1
            Down
            ::

            You could try to upload your files without the fileuploader widget.
            For task like that you can use cordova-plugin-file-transfer which is part of the Simplifier client. You can find a documentation of the API on Github.

            Dinkel
                Has successfully completed the online course Introduction
                Has successfully completed the online course Intermediate (200)
                Has successfully completed the online course Advanced (300)
                Has successfully completed the online course Basics (100)
              5 years ago #18006
              Up
              0
              Down
              ::

              Just for my understanding: You just want to use a click event of a button, right?
              This should work like on your PC. There shouldn’t be any differences.

              jonas.rausch
                  Has successfully completed the online course Introduction
                  Has successfully completed the online course Intermediate (200)
                  Has successfully completed the online course Advanced (300)
                5 years ago #18007
                Up
                0
                Down
                ::

                Hi Julia,

                 

                Can you describe how you added the click event to the Button?

                Did you add it via JQuery or are you using the native Ui5 events?

                 

                Julia
                    5 years ago #18009
                    Up
                    0
                    Down
                    ::

                    Hi Jonas,

                    yes, JQeury.

                    var fileUploader = $('#Create_Image--ui_unifed_FileUploader-fu');
                    if (fileUploader !== null)
                    fileUploader.click();

                    Best regards!
                    Julia

                    Julia
                        5 years ago #18060
                        Up
                        0
                        Down
                        ::

                        Hi Jonas,

                        I’ve tried this before. Doesn’t work šŸ™

                        Best regards
                        Julia

                        Dinkel
                            Has successfully completed the online course Introduction
                            Has successfully completed the online course Intermediate (200)
                            Has successfully completed the online course Advanced (300)
                            Has successfully completed the online course Basics (100)
                          5 years ago #18064
                          Up
                          0
                          Down
                          ::

                          What are you trying to achieve? I see you use a fileuploader probably for an image. Maybe there is a different solution,

                          Julia
                              5 years ago #18065
                              Up
                              0
                              Down
                              ::

                              I try to reduce the tip actions for the users.

                              When the dialog with the file uploader opens, i want the file uploader button to be “pressed” automatically, so the users don’t have to press the button every time they take a picture (they’ll take a lot of pics every day).

                              It would be best to also start the camera automatically and have an “upload from device” function in the camera as usual on a iPhone. But that’s optional.

                              jonas.rausch
                                  Has successfully completed the online course Introduction
                                  Has successfully completed the online course Intermediate (200)
                                  Has successfully completed the online course Advanced (300)
                                5 years ago #18070
                                Up
                                0
                                Down
                                ::

                                Hi Julia,

                                 

                                Could you describe your use case in a few words?

                                 

                                If you are using a Ui5 button, you can call the press event via script like this:

                                sap.ui.getCore().byId(“[buttonID]”).firePress()

                                 

                                If its a “normal” Html button, you first need to attach a press event via script and then fire it via script.

                                Dinkel
                                    Has successfully completed the online course Introduction
                                    Has successfully completed the online course Intermediate (200)
                                    Has successfully completed the online course Advanced (300)
                                    Has successfully completed the online course Basics (100)
                                  5 years ago #18072
                                  Up
                                  0
                                  Down
                                  ::

                                  You try the following:
                                  Add a button (sap.m.Button) and add the following to the press event like you did in a post above.

                                  var fileUploader = $(‘#Create_Image–ui_unifed_FileUploader-fu’);
                                  if (fileUploader !== null)
                                  fileUploader.click();

                                  Then add to the onAfterRendering of your screen the following code:

                                  $(‘#Create_Image–ui_unifed_FileUploader-fu’).change(function() {
                                  $(‘#Create_Image–ui_unified_FileUploader1-fu_form’).submit();
                                  });

                                  Now hide the button with a CSS rule which says

                                  display: none;

                                  Now you can trigger the hidden button with

                                  sap.ui.getCore().byId(“Id_Of_The_Button”).firePress()

                                  On this way the file chooser will appear automatically.

                                  @jonas.rausch You can’t fire the press event on this way because she uses sap.ui.unified.FileUploader which is a form with an input of type file.

                                  Julia
                                      5 years ago #18074
                                      Up
                                      0
                                      Down
                                      ::

                                      Hi Jonas,

                                      I’ve described the case in the message above šŸ™‚

                                      I’m using a button of the type “io.simplifier.widgets.FileUploader_FileReader”. You know this type?

                                      unfortunately, .firepress() doesn’t work either.

                                      Thank you very much for your help!
                                      Julia

                                      Julia
                                          5 years ago #18076
                                          Up
                                          0
                                          Down
                                          ::

                                          Hi Dinkel,

                                          I’ll annotated your post in bold letters here.

                                          ___________

                                          Add a button (sap.m.Button) and add the following to the press event like you did in a post above.
                                          I guess you mean a additionally button in the same screen as the FileUplaoder? Ok, done that.

                                          var fileUploader = $(ā€˜#Create_Imageā€“ui_unifed_FileUploader-fuā€™);
                                          if (fileUploader !== null)
                                          fileUploader.click();

                                          Then add to the onAfterRendering of your screen the following code:
                                          You mean to the screen containing the buttons, right? Ok …

                                          $(ā€˜#Create_Imageā€“ui_unifed_FileUploader-fuā€™).change(function() {
                                          $(ā€˜#Create_Imageā€“ui_unified_FileUploader1-fu_formā€™).submit();
                                          });

                                          Now hide the button with a CSS rule which says
                                          I’ve guessed you mean I should hide the new button? Ok …

                                          display: none;

                                          Now you can trigger the hidden button with
                                          Done that too …

                                          sap.ui.getCore().byId(ā€œId_Of_The_Buttonā€).firePress()

                                          On this way the file chooser will appear automatically.
                                          But unfortunately nothing happens.

                                          __________

                                          Have I done something wrong?

                                          Best regards
                                          Julia

                                          Mathieu Roll
                                              Has successfully completed the online course Introduction
                                              Has successfully completed the online course Intermediate (200)
                                              Has successfully completed the online course Advanced (300)
                                              Has successfully completed the online course Basics (100)
                                            5 years ago #18195
                                            Up
                                            0
                                            Down
                                            ::

                                            Hello Julia,

                                            for Desktop and iOS you can use this Code.

                                            $(sap.ui.getCore().byId(“Create_Imageā€“ui_unifed_FileUploader”).FUEl).trigger(“click”);

                                            On Android this doesn’t work because google is blocking it and you will only get an error messge saying.

                                            “File chooser dialog can only be shown iwth a user activation.”

                                             

                                            An other way to create and read pictures is by using the mobile action (Capture Image).

                                            The Mobile Action is giving back a FileUrl and with the Client Side Business Object SIMP_FileHelper and the Function readFileByUrl you can read the Image.

                                            It is giving you back the blob and base64 for the Image with the given FileUrl.

                                            If you do not have the Business Object you can download it from Here

                                            Note: The Mobile Action can only be used with our Simplifier Mobile Client for iOS nad Android

                                            Julia
                                                5 years ago #18240
                                                Up
                                                0
                                                Down
                                                ::

                                                Hello Malfurion,

                                                unfortunately, this doesn’t work either.

                                                We’re using the ui-FileUploader so we also have the upload from device function.

                                                Best regards
                                                Julia

                                              Viewing 15 posts - 1 through 15 (of 16 total)

                                              You must be logged in to reply to this topic.