0

I have a SegmentedControl on my Page and I want to call methods on a C++ object when the selected value has changed. Each selectable Option has its own method to call.

I need to know if the Option was set by touch or by code, because if the method execution fails, I want to set the old value by code.

Example:

  1. I set Option B by touch
    1. Option B's assigned method gets called
    2. the called method succeeds
  2. I set Option B by touch
    1. Option B's assigned method gets called
    2. the called method failed
    3. Option A is being set by code
    4. I don't want Option A's assigned method to get called, because the Option has been set by code

How can I detect if the Option has been set by code or by touch?

pinki
  • 902
  • 2
  • 12
  • 29

1 Answers1

0

I don't know if you can detect by touch or code. But you can make a workaround.

property bool byTouch: true

Let's go through your example

  1. I set Option B by touch
    1. Option B's assigned method gets called
    2. the called method succeeds
  2. I set Option B by touch
    1. Option B's assigned method gets called
    2. the called method failed
    3. Option A is being set by code, I set byTouch to false
    4. I check if byTouch is true, and if it is, Option A's assigned method to get called

You can obviously make the same byTouch check for Option B as well.

Bojan Kogoj
  • 5,321
  • 3
  • 35
  • 57