Text

ITC, change position of wordRange into SmartPage

Hello,

Working an app for android devices.

I want to change position of object when I selected (gesture selection) a wordrange from smartpage.

How I can do that?

This feature, as I can see, exist to the original smartnote app for android devices. I can't find any sample that has this feature.

Best regards,
Kyriakos


Dear Kyriakos,

first, in order to provide you with a proper answer, can you confirm the ATK widget you are using? Are you using the ITC, Single Line...?

Best regards,

Olivier

Hi Olivier,

I'm using the ITC (Interactive Text Component) ATK WIDGET.

Best regards,

Kyriakos

For such use case, you need to set the following listener on your smartpage:

setSmartPageGestureListener(ISmartPageGestureListener listener)
ISmartPageGestureListener
void selectionGesture(SmartPage smartPage, List<SmartStroke> gestureStrokes, WordRange wordRange)


For more details, see:
http://doc.myscript.com/MyScriptATK_1.3/Android/itc/ref_android/com/myscript/atk/itc/SmartPage.html
http://doc.myscript.com/MyScriptATK_1.3/Android/itc/ref_android/com/myscript/atk/itc/ISmartPageGestureListener.html
It will allow to detect selection gestures and register selected words or strokes on your page, you will then be able to use the following methods to move your strokes or words:
createMovedStroke(SmartStroke stroke, float dx, float dy, int strokeType)
http://doc.myscript.com/MyScriptATK_1.3/Android/itc/ref_android/com/myscript/atk/itc/StrokeFactory.html
createMovedWord(SmartWord word, float dx, float dy, int spaceBefore)
http://doc.myscript.com/MyScriptATK_1.3/Android/itc/ref_android/com/myscript/atk/itc/WordFactory.html
Hope it helps.
Best regards,

Hello Cate,

Thanks for response.

So, I try to use the above functions but I cant see any move or update to the screen.

I am trying to understand the itc atk and I use the itc-sample. I change the code of the selectionMethod to look like:


 @Override
 public void selectionGesture(final SmartPage smartPage, final List<SmartStroke> gestureStrokes, WordRange wordRange) {
  if (!mGesturesConfig[SmartGestureType.SELECTION - 1][1]) {
   mSelectedWordRange = wordRange;

   // Apply the underline property on the given word range
   mUserParamsFactory.applyWordPropertyOnWordRange(wordRange, WordProperty.SELECTED, null);
   ((SampleActivity) mContext).onSelectedWordRange();

  }

 
  Handler mainHandler = new Handler(mContext.getMainLooper());
  mainHandler.post(new Runnable() {
   @Override
   public void run() {
    // Invalidate each SmartWord view
   
    for (final SmartStroke smartStroke : gestureStrokes){
     
     SmartStroke dummy = smartPage.getStrokeFactory().createScaledStroke(smartStroke, 200, 300, smartStroke.getStrokeType());
     mITCModelItemListener.onStrokeAdded(dummy);
     }
   }
  });
  
  

  triggerGestureUINotifiaction(SmartGestureType.SELECTION - 1);
 }


I cant see any scale stroke...

I updated my code to look like:


 @Override
 public void selectionGesture(final SmartPage smartPage, final List<SmartStroke> gestureStrokes, WordRange wordRange) {
  if (!mGesturesConfig[SmartGestureType.SELECTION - 1][1]) {
   mSelectedWordRange = wordRange;

   Handler mainHandler = new Handler(mContext.getMainLooper());
   mainHandler.post(new Runnable() {
    @Override
    public void run() {
     // Invalidate each SmartWord view
     List<SmartStroke> replaceStrokes = new ArrayList<SmartStroke>();
     for (final SmartStroke smartStroke : gestureStrokes) {
      replaceStrokes.add(smartPage.getStrokeFactory().createScaledStroke(smartStroke, 200, 300, smartStroke.getStrokeType()));

     }

     updateSmartStrokeUIInMainThread(gestureStrokes, replaceStrokes);
    }
   });
  }
 }

 private void updateSmartStrokeUIInMainThread(final List<SmartStroke> removedStrokes, final List<SmartStroke> addedStrokes) {
  Handler mainHandler = new Handler(mContext.getMainLooper());
  mainHandler.post(new Runnable() {
   @Override
   public void run() {
    mPageInterpreter.getPage().removeStrokes(removedStrokes);
    mPageInterpreter.getPage().addStrokes(addedStrokes);
   }
  });
 }

Still not working...

Finally, with some changes, it works.

An another question. I am trying to get x,y coordinates from OnTouchListener of pageview but this is not working. Is this the correct way to move an item to smartpage when my pen is on screen or there is any custom listener that I can do this?

Best regards,
Kyriakos

Hello,

Indeed you will not be able to receive onTouch events on the PageView as it is a FrameLayout and its children views intercept the touch events. You can refer to the android documentation for a better understanding
http://developer.android.com/training/gestures/viewgroup.html.

I hope this will help you in your integration.
Best regards.

Login or Signup to post a comment