Announcement

Collapse
No announcement yet.

Acquiring value of internal control using code

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

  • Acquiring value of internal control using code

    Hello,

    I have a Visi Genie project with a small amount of magic touch code. I simply want to change the display brightness using a slider control. A project using a standard graphical slider control works fine. I use the following MagicTouch code to achieve this:

    Code:
    if (ImageTouched == iSlider0)
       sVal := (img_GetWord(hndl, iSlider0, IMAGE_INDEX));
       if (sVal > 0)
            gfx_Contrast(sVal);
       endif
    endif
    If I attempt to use an internal slider control, and I change the code to reference the internal slider control, this code no longer works. I'm assuming it's because the IMAGE_INDEX isn't supported for the internal control. So, is there a way to acquire the value of an internal object using magic code?

  • #2
    Hi Gary,

    It would be a lot easier if you simply use MagicEvent rather than MagicTouch.

    MagicEvents are pieces of code which can be linked to UI widgets.

    In your MagicEvent, simply write:

    Code:
    func MagicEvent0(var newval)
        if (newval > 0)
            gfx_Contrast(newval);
        endif
    endfunc
    And set your Slider / Internal Slider's OnChanged and/or OnChanging Event to the MagicEvent you created.

    Click image for larger version

Name:	MagicEvent.jpg
Views:	27
Size:	19.7 KB
ID:	74289

    I hope this helps.

    Best Regards
    Juniel Cruz

    Comment


    • #3
      Thank you Juniel! I tried this and it works fine.

      Is there a simple way from within this magic event code to generate a GENIE message to the host sending the value from the control?

      rgds,

      Gary

      Comment


      • #4
        Hi Gary,

        I assume you mean for the slider to still report the event.

        There are two simple ways you can do this:
        1. Set Slider's OnChanged event to Report Message as you would normally do to send data from display to host controller and set its OnChanging event to the MagicEvent as shown in my previous reply. This effectively triggers the MagicEvent while you are moving the slider and sends the report once you are done.
          .
        2. Use one of ViSi Genie Magic's callable function SendReport
        Click image for larger version

Name:	SendReport.png
Views:	34
Size:	32.1 KB
ID:	74297

        In your code, it would be:
        Code:
        func MagicEvent0(var newval)
            if (newval > 0)
                gfx_Contrast(newval);
                SendReport(REPORT_EVENT, tiSliderE, 0, newval);
            endif
        endfunc

        I personally recommend the first option since it minimizes the messages that is sent by the display and processed by the host.

        I hope this helps.

        Best Regards
        Juniel Cruz

        Comment


        • #5
          Sorry for the late reply but thanks again for this, Juniel. This is exactly what I was looking for.

          There is still an issue but I think it might be specific to our (custom) Pixxi display model - Gen4-LITE-43PT-u [v1.6]

          What happens is that the internal slider does properly register the touch but it never updates the indicator text value or the virtual slider knob graphic. It always displays the max value.

          I've deleted the internal slider control, re-added it, tried pasting down multiple internal slider controls, checked the min and max ranges, nothing fixes this.

          The traditional slider control works fine and does not have issues. Maybe something for your dev team to look at.

          best,

          Gary

          Comment


          • #6
            Hi Gary,

            Thanks for reporting this to us.

            I tried recreating your issue but I can't seem to do so.

            Click image for larger version

Name:	internalSlider.png
Views:	11
Size:	498 Bytes
ID:	74370
            Is this the widget you are referring to?

            Also, can you recreate this in a small project and send it to me?

            The slider above is one with the default parameters and it seems to work fine for me. Could you test if the default values behave the same for you too?

            Best Regards
            Juniel Cruz

            Comment


            • #7
              Hi Juniel,

              Yes, that is the widget.

              I'm hoping you can load the attachment.

              Ths is our project for display Pixxi Gen4-LITE-43P4T-u [v1.6]

              The project file is OR4000NGX_PixxiPorject.4DGenie

              If I scale the project down to just a few forms, the internal slider control works correctly.

              With the full project, the internal slider control "sticks" and can not be moved after the initial touch. The attached project demonstrates this.

              This control is on Form9 (System Settings).

              You can get to this form using GTX or from the main menu by pressing Settings button, and then using the menu on the top of the screen, go to the "System" page (furthest to the right).

              Thanks again for looking at this,

              Gary

              Attached Files

              Comment

              Working...
              X