[toolchain-2.0] mouse events in UITextView

Discussion in 'iOS Development' started by gomegom, Aug 25, 2008.

  1. gomegom

    gomegom New Member

    Joined:
    Jul 12, 2008
    Messages:
    3
    Likes Received:
    0
    Hi,

    how could we handle events like mouseDown, mouseDragged and mouseUp events for an editable UITextView object when developping an application for 2.0 framework?

    As these operations change the cursor position (at least mouseDragged and mouseDown do), I tried to implement textViewDidChangeSelection, thinking they might be the same thing. Unfortunately, it did not help much as -ironically- it seems like it is only fired after a mouseUp event, not at all cursor position changes.

    It seems like a very task but I couldn't find a way around. No need to confess I am new to obj-C

    Please Register or Log in to view images



    Sorry for being an asker at first post, I hope someone can help me about this problem.

    Thanks all in advance
  2. ipodtouchmaster05

    ipodtouchmaster05 Well-Known Member

    Joined:
    Sep 30, 2007
    Messages:
    1,787
    Likes Received:
    41
    Device:
    iPhone 5 (Black)
    It changed to touches now, like touchesDown touchesEnded touchesMoved etc..
  3. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    ipodtouchmaster05, Please remove the SDK method names from your post. They are still protected under NDA.
  4. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    Woah, even the names are under Apple's NDA? I knew it was strict but no that strict.
  5. gomegom

    gomegom New Member

    Joined:
    Jul 12, 2008
    Messages:
    3
    Likes Received:
    0
    I did not know you couldn't even post the function names

    Please Register or Log in to view images


    Anyway, thanks for the reply, it was much more faster then I expected.
    Unfortunately I had not been succesful about using the touches* operations too.

    Actually, I tried them before but after many unsuccesful attempts I gave up. After seeing your reply, I decided to create a basic example with just a textView.

    Seeing the NDA thing, I am not sure if I can share the code I have written, actually I do not have much of a code. Just a basic "Hello World" application which displays an editable UITextView object with the string I provided. All these part is handled in applicationDidFinishLaunching portion

    Besides applicationDidFinishLaunching, I add those sacred SDK method definitions and implement them with simple things like [textView setText

    Please Register or Log in to view images

    "asdfgghjk"]; just to see if it is working. Unfortunately, it does not seem to work.

    Meanwhile, I found an example called HelloSlider which uses those NDA-protected operations. My example seems to be in 1to1 correspondance with it but still no help.

    I would appreciate any guidance.
  6. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
  7. gomegom

    gomegom New Member

    Joined:
    Jul 12, 2008
    Messages:
    3
    Likes Received:
    0
    (I deleted my previous post while editing this one

    Please Register or Log in to view images

    I had a problem about the example that the texts were not editable and when I managed to make them editable, the touches* methods were not handled like it did in that sample. Thanks for it again by the way.)

    OK, I believe I solved the problem, here is the method if anybody asks:

    I subclassed the UITextView and implemented only four methods within it; one is canBecomeFirstResponder which has just "return YES;" in it.

    The other three methods are the "sacred" touch events. If you fill the implementations for them, you can catch the events but now the UITextView does not receive the events so cannot show the cursor, thus can not be edited. To avoid this, just send the event to super class by something like [super touches"DidSomething":touches withEvent: event ];

    Thanks for directing me towards the right path

    Please Register or Log in to view images

    I hope this information can be useful for someone else.
  8. arjit

    arjit New Member

    Joined:
    Apr 24, 2009
    Messages:
    1
    Likes Received:
    0

Share This Page