0

keyboard.appendToValue() doesn't work?

Is there a known issue with KONtx.control.Keyboard.appendToValue()?

When I call the function it doesn't seem to append to the keyboard's value. Immediately after I call it I see an event with the value the keyboard had before the call to append.

I would expect these two sequences to do the same thing, but only the second works.

Broken:
CODE
    tc.keyboard.appendToValue(" add B C:V");


Works:
CODE
    tc.keyboard.setValue(tc.keyboard.getValue() + " add B C:V");

by
10 Replies
  • Perhaps appendToValue() doesn't have this issue, but the setValue(getValue() + "xxx") work-around I described in my previous message does.

    After appending "xxx" to the keyboard's string (assume it is "abc") the (invisible?!) cursor is still after "abc" and not after "abcxxx". So typing Z results in "abcZxxx" instead of "abcxxxZ", delete similarly deletes from the middle of the string giving "abxxx" instead of "abcxx". There doesn't seem to be any API to move the cursor or get any information about it.

    Are there examples or documentation I am missing?
    0
  • The following does not move the cursor to the end of the string, nor move it to the beginning. It looks like clearValue() doesn't work. If the keyboard had "abc", I clear the keyboard, then set the value to "abcxxx", the invisible cursor is still after the c.

    CODE
        temp = tc.keyboard.getValue();
    tc.keyboard.clearValue();
    result = tc.keyboard.setValue(temp + " add B C:V");


    Any pointers? Hints??
    0
  • the following should work:

    CODE
    tc.keyboard.setCursorPosition(tc.keyboard.getValue().length);

    ...arguably this should be handled when you set a new value right ?


    We are aware that the current implementation of the keyboard is lacking in documentation and examples. We are working on the next generation of the keyboard which will make working with the keyboard easier for you guys.
    0
  • I will try that.

    How can I edit my posts, as you have edited yours?
    0
  • editing posts is reserved for moderators
    0
  • QUOTE (Eric Fehrenbacher @ Jan 18 2011, 11:30 AM) <{POST_SNAPBACK}>
    the following should work:

    CODE
    tc.keyboard.setCursorPosition(tc.keyboard.getValue().length);

    ...arguably this should be handled when you set a new value right ?


    I agree, seems to me append should move the cursor.

    That code doesn't work for me. If the user types "abc" then presses a button so that " b c:v" is appended, then the user types "xyz", what I see is "abcxyz b c:v" This has been logged as a bug against a widget we are trying to release. I really do need a workaround/solution to this problem. Here is the code where I append a string to the keyboard:

    CODE
                    temp = tc.keyboard.getValue();
    tc.keyboard.clearValue();
    result = tc.keyboard.setValue(temp + TVL4.last_bcv);
    tc.keyboard.setCursorPosition(tc.keyboard.getValue().length);


    And here is part of the debug log:

    CODE
    WE 00:00:41:794: [T:2602] !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    WE 00:00:41:794: [T:2602] ERROR!ERROR!ERROR!ERROR!ERROR!
    WE 00:00:41:794: [T:2602] !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    WE 00:00:41:794: [T:2602] TypeError: tc.keyboard.setCursorPosition is not a function (customtweetview.js: Line 105)


    p.s. Moderator: It may be a good idea to re-open the previous version of this thread and move this message there.
    0
  • Can you give me the identifier of the app you submitted. I need to look at the code to help resolved this. Yes the keyboard interface is a little messed up. Typically authors interact with the keyboard through another interface which is more normalized. I'm guessing that you are not implementing a valueManager to handle the value from the keyboard but, like I said, I need to see the code to move forward otherwise I am just guessing.

    I will look at the code and provide feedback as soon as I get the id.
    0
  • QUOTE (Eric Fehrenbacher @ Feb 16 2011, 12:40 PM) <{POST_SNAPBACK}>
    Can you give me the identifier of the app you submitted.

    Thank you for looking at the code. The most recent submission is tv.l4.totd, it is version 1.0.0. The most recent code is tv.l4.totd.201102.1503.widget which includes the suggested line of code, and I think addresses all bugs open against version 1.0.0. Look in the file ...Javascript/views/customtweetview.js

    Jay
    0
  • I updated my gist on github:
    https://gist.github.com/613789

    1) the appendToValue method was never remapped to the valueManager
    2) the clearValue method did not reset the cursorPosition after setting a new value

    You should be able to update your "keyboardpatch.js" with the code from that "Gist" and then use the "appendToValue" method as expected

    tc.keyboard.appendToValue("WHATEVER");

    Note: this will insert the string value "WHATEVER" starting at the current cursorPosition.
    Hint: the cursorPosition could be updated prior to using this method to change the insertion point

    FYI:
    The idea is to use the insertCharacter method off the valueManager instance to inject a value mid-stream(you could replace the entire value with your own string). either way once done you need to update the cursorPosition which doesn't happen automatically in this version. This is one of the things handled for you in the next version of the keyboard.
    0
  • Thank you! The new gist, and switching back to .appendToValue() has fixed the problem for me.

    Jay
    0

Recent Posts

in Design / Interaction - Yahoo! TV Widgets