Announcement

Collapse
No announcement yet.

Pop-up keyboard

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Pop-up keyboard

    Hi,
    I want to use a keyboard to enter a value into a variable. Is it possible to have a pop-up keyboard? Just like on a smartphone or tablet.
    So the ideal way would be:
    1. Touch the leddigits which is displaying the value of the variable. The keyboard would then appear. Everything else on the screen should still be displayed (except whatever the keyboard is covering up).
    2. I enter my value using the keyboard, then touch an "Enter" or "Accept" key.
    3. The variable is set to the new value, and the keyboard disappears. Screen is back to whatever it was displaying before.

  • #2

    Good day Koganei,

    First, what 4D Programming environment are you using? It is possible to have a pop-up keyboard in your project
    when you are using the ViSi or ViSi-Genie Magic environment.

    However, the problem would the keyboard disappearing, as the objects and widgets in the 4DGL environment is being
    placed on top of each other. Clearing the whole screen (form) must be performed to remove the widget and show all
    the desired objects/widgets again.

    The keyboard widget has editable buttons, output values and configurable size depending on your preferences.

    To implement this scenario on the ViSi programming language, you should "enable" a "touch event" on the LED
    Digits, so whenever the LED Digits is pressed, a keyboard will show (pop-up)

    I hope this helps, please let me know if you need more information.

    Comment


    • #3
      Hi Mark,
      I am using ViSi.
      I think I know what you mean. So I would have a function that draws all the objects on my form (excluding the keyboard), then on the LED digits touch event, I would draw the keyboard. Once the keyboard has output a value, I call gfx_Cls() and then call the function to draw my form again?

      In the appnote regarding multiple forms, when I switch forms, I have to disable touch on the old form and also on every object on that form. Do I have to do this with the objects behind the keyboard when it "pops up"? What about for the keyboard when it "disappears"?

      Comment


      • #4
        To make the LED Digits a "Touchable event" you can use the:

        img_ClearAttributes(hndl, iLeddigits1, I_TOUCH_DISABLE);

        Yes, the procedure on the first paragraph is correct way to do it. Regarding your question about the multiple forms, you need to disable all unnecessary objects on that form. In your scenario, you need to do this to the objects behind the keyboard, and after the keyboard disappears. You can disable the object by using this syntax code:

        img_SetAttributes(hndl, iKeyboard1, I_TOUCH_DISABLE);

        In my personal experience in coding 4DGL, I can suggest that you create a sub-routine function that will disable all objects, then create sub-routine functions to draw/show and activate touch detection of the objects, this will minimize your code and make disabling easier, for example:

        Objects in form 1:
        winbutton1
        winbutton2
        keyboard

        Object in form 2:
        coolgauge

        func disableallobjects()
        //disable winbutton1
        //disable winbutton2
        //disable keyboard
        //disable coolgauge
        endfunc

        func form2()
        //show/draw coolgauge
        endfunc

        so on your desired execution, when you show the form 2:

        disableallobjects(); //disable all objects first
        form2(); //show/enable the necessary objects


        Also please take note that when you use an image as a background to the form, you need to include it to the objects to be disabled, it is a good practice that when you paste the code of the form to your program, you should add this after. In my experience, I perform this inside my display form sub routine functions:

        func displayForm1()
        img_Show(hndl,iForm1) ; //This is what you paste from the Object Inspector
        img_SetAttributes(hndl, iForm1, I_TOUCH_DISABLE);
        endfunc

        Comment


        • #5
          Hello,

          I have a question related to making LED digits a touchable event. I am trying to make this a reportable event to the arduino. Can you give me an example of how I may do this. I want to use this to select which led digit the user wants to change with an up/down button.

          Thanks,

          Mark

          Comment


          • #6
            when using visigenie i noticed changing the form (even tho it's on the same one) but switching to it again will reload the entire form, not sure it'll work on another visi environment, but if i did a keyboard popup for example, i'd just geniewrite genie_obj_form (same form) to reload the same form

            Comment


            • #7
              This refers to the question how to make an LED digit a touchable event. In the Magic Touch Event I have:

              img_ClearAttributes(hndl, iCustomdigits25, I_TOUCH_DISABLE);

              if (ImageTouched == iCustomdigits25)
              WriteObject (tUserled, 62, 1);

              This works, however it locks up the screen. What do I need to add to correct this?

              Thanks for the help guys,

              Mark

              Comment


              • #8
                hi markl,

                That is preferable to do in the Visi Environment.

                Another way is you can try getting the x and y values when a touch occurs and compare it to x and y region of the custom digits inside MagicTouch.
                (attached is a sample project)

                Code:
                    x := touch_Get(TOUCH_GETX);
                    y := touch_Get(TOUCH_GETY);
                
                    if (ImageTouched == iWinbutton0)
                        print("button 1 \n");
                         WriteObject (tUserled, 0, 0);
                    endif
                
                    print("x: ",x,"\n");
                    print("y: ",y,"\n");
                
                    if ((x>104)&&(x<235)&&(y>170)&&(y<230))
                        print("Custom Digits 1 \n");
                        WriteObject (tUserled, 0, 1);
                    endif
                Hope this helps,
                Attached Files

                Comment


                • #9
                  Thank you for your help, yes, I can make the display respond to the touch of an area, but I would like to send a report to the arduino if the area ,not iWinbutton0, is touched. What would the format be of the statement to do that?

                  Also, what would the arduino code look like to receive this report:

                  if ( Event.reportObject.index == ?)
                  {
                  button_flag = 1;
                  }

                  etc..

                  Thanks
                  Last edited by markl; 6th February 2017, 11:07 PM.

                  Comment


                  • #10
                    Hi markl,

                    You could try sending Report_Event Magic bytes and receive them through serial like these:

                    Magic Bytes Event Error
                    http://forum.4dsystems.com.au/forum/...es-event-error

                    REPORT_MAGIC_EVENT_BYTES bad respons3
                    http://forum.4dsystems.com.au/forum/...op-up-keyboard

                    Also, you could try something like this one: (not recommended as above though as this assigns an object-40 not used in the library)

                    Code:
                    // MagicTouch
                        x := touch_Get(TOUCH_GETX);
                        y := touch_Get(TOUCH_GETY);
                    
                        if (ImageTouched == iWinbutton0)
                            print("button 1 \n");
                            WriteObject (tUserled, 0, 0);
                        endif
                    
                        print("x: ",x,"\n");
                        print("y: ",y,"\n");
                    
                        if ((x>104)&&(x<235)&&(y>170)&&(y<230))
                            print("Custom Digits 1 \n");
                            WriteObject (tUserled, 0, 1);
                    
                            SendReport(REPORT_EVENT,40,0,0);   // 40 was assigned to Object variable for customDigits
                    
                        endif
                    Receiving on Arduino code:
                    Code:
                    void myGenieEventHandler(void)
                    {
                      genieFrame Event;
                      genie.DequeueEvent(&Event); // Remove the next queued event from the buffer, and process it below
                    
                     if (Event.reportObject.cmd == GENIE_REPORT_EVENT)
                      {
                        if (Event.reportObject.object == 40)                              // If the Reported Message was from the object = 40
                        {
                          if (Event.reportObject.index == 0)                              // If UserLed0 (Index = 0)
                          { 
                             //Serial.println("custom digit press");
                            // button_flag = 1;
                          }
                        }
                      }
                    Hope this helps,

                    Comment


                    • #11
                      Joseph,

                      The touch area defined by x and y work perfectly, thank you. The Object Variable was the key I was looking for.
                      It's so much easier to use the serial com that is already set up through Visi Genie.

                      Regards,

                      Mark

                      Comment


                      • #12
                        Hey Guys,

                        I have a question, with this command SendReport(REPORT_EVENT,40,12,0);

                        What is the function of the last variable, 0 in this statement ? How does it modify the command?
                        I have tried changing the 0 to a 1 and 2 and it doesn't seem to make any difference, I would like to be able to count button presses.

                        Regards,

                        Mark

                        Comment


                        • #13
                          Good day markl,

                          The SendReport() function sends a standard 6 byte report object or event packet to the genie serial port. The 4th parameter to fill is the value. This is not much noticeable for button objects especially if they are only "momentarily:YES" they only go on 0 or 1 states.

                          I suggest that you just use/make a variable for counting button presses in your Arduino code.

                          You can view the other Visi-Genie functions through the ViSi-Genie Reference Manual:
                          http://www.4dsystems.com.au/product/..._IDE/downloads

                          or just click the F1 button when you open a ViSi-Genie project.
                          Attached Files

                          Comment

                          Working...
                          X