Cut & Paste Scrolling issues

Discussion in 'Questions (Windows Mobile)' started by tsteward, Jan 26, 2009.

  1. tsteward

    tsteward Active Member Licensed User

    With my code below I get annoying scroll action.

    On a long page if I cut or paste My code scrolls to the end of the pasted text. If it is only one word it scrolls so as this word is at the bottom of the text box. If I don't set the scroll position I end up at the top.

    How can I paste and not have the textbox move at all. If I press Control V it behaves as I want. However if I put the keydown, keypress code into the paste button nothing happens.

    Code:
    Case 18 'btnPaste
      If TextEdit.SelectionStart > -1 Then
       i = TextEdit.SelectionStart
       
    If TextEdit.SelectionLength > 0 Then 'The pasted text should replace the selection.
         TextEdit.Text = StrRemove(TextEdit.Text,i,TextEdit.SelectionLength)
       
    End If
       
    If cPPC Then 'Paste from the clipboard on the device
         s = clip.GetClipboardData
       
    Else 'Paste from the global variable on the desktop
         s = DesktopString
       
    End If
       TextEdit.Text  = StrInsert(TextEdit.Text,i,s)
       TextEdit.SelectionStart = i + StrLength(s)
       TextEdit.ScrollToCaret
    '    TextEdit.Focus
    '    Hardware.KeyDown(17)
    '    hardware.KeyPress(Asc("V"))
    '    hardware.KeyUp(17)
      End If
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Setting the textbox text property will reset the caret position.
    However the following code works fine:
    Code:
    Sub Globals
        
    'Declare the global variables here.

    End Sub

    Sub App_Start
        Form1.Show
        hardware.New1
    End Sub

    Sub Button1_Click 'cut
        textbox1.Focus
        hardware.KeyDown(
    17)
        hardware.KeyPress(
    Asc("X"))
        hardware.KeyUp(
    17)
    End Sub

    Sub Button2_Click 'Paste
        textbox1.Focus
        hardware.KeyDown(
    17)
        hardware.KeyPress(
    Asc("V"))
        hardware.KeyUp(
    17)
    End Sub
     
  3. tsteward

    tsteward Active Member Licensed User

    Gday Erel,
    As you can see by my commented out code above I did try that. Unfortunately it doesn't work. Not in my program anyway.

    Thanks for your ever vigilant watch over this forum. Your a good person to deal with & what you charge for B4PPC is not enough for the support you give.

    Thanks
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Thanks.

    However if you can please test the attached program on your device and tell me if it worked or not. Ive tested it on several devices and it works fine.
    I want to add similar functionality to the device editor.
     

    Attached Files:

    • 1.sbp
      File size:
      789 bytes
      Views:
      62
    Last edited: Jan 27, 2009
  5. agraham

    agraham Expert Licensed User

    Am I being stupid :confused: That program does nothing on my Axim X30 (WM2003SE), nor my HTC Diamond (WM6.0) nor my HP iPAG214 (WM6.1)! It's so simple, I copied 1.sbp and the Hardware.dll to the device and ran the program in the IDE, selected some text, pressed Cut - nothing! Ctl-X and Ctl-V on the SIP work fine.

    EDIT :- You've left the Textbox1.Focus statements out Erel :signOops:
     
    Last edited: Jan 27, 2009
  6. Erel

    Erel Administrator Staff Member Licensed User

    Sorry :(
    texbox1.focus was missing in the attached file.
    I'll update the file.
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    So it works fine now?
     
  8. agraham

    agraham Expert Licensed User

    Yes, I've been round all three again and it looks OK on all three now, including not scrolling the textbox to the bottom on a long bit of text
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    Thanks agraham! :sign0188:
     
  10. agraham

    agraham Expert Licensed User

    I see you have a test for a device in the code implying that you also run it on the desktop. HardwareDesktop is mainly a dummy so this doesn't work on the desktop.
     
  11. tsteward

    tsteward Active Member Licensed User

    Ok, Erel your sample works well. Not sure why my program won't allow it to work. :(
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice