+ Reply to Thread
Results 1 to 4 of 4

Thread: How do I make a proper editable multi-line text field?

  1. #1
    Soulwalker
    Join Date
    Sep 2011
    Posts
    19

    Default How do I make a proper editable multi-line text field?

    I've banged my head on this problem for days now and have exhausted all my ideas.

    For an editable text field, the only thing that I have found is the RiftTextField UI Element.

    Working with that however, makes me realize that multi-line functionality is not baked in. I read that I need to implement it manually, so I tried a simple workaround of detecting an "Enter" key press followed by manually inserting a newline character.

    Even that however seemed impossible. All the key events that I could think to hook to didn't give anything useful.

    Code:
    Event.UI.Input.Key.Down
    Event.UI.Input.Key.Down.Bubble	
    Event.UI.Input.Key.Down.Dive
    The first parameter is useless for my needs, the second parameter is supposed to be a keycode but... it CHANGES every time, even for the same keypress.



    I've also tried looking at other addons (LuaPad, Notepad) but they are also broken (no newline on enter).

    Does anyone know of a working implementation present in an existing addon that I could look at, or a general solution to this problem?

  2. #2
    Plane Touched
    Join Date
    Feb 2012
    Posts
    228

    Default

    I have this on BiSCal:
    Code:
        descriptionText:EventAttach(Event.UI.Input.Key.Down,
            function(self, h, key)
                if key == "Return" then
                    local cursor = self:GetCursor()
                    local startPosition, endPosition = self:GetSelection()
                    startPosition = startPosition or cursor
                    endPosition = (endPosition or cursor) + 1
                    local text = self:GetText()
                    self:SetText(text:sub(1, startPosition) .. "\n" .. text:sub(endPosition))
                    self:SetCursor(startPosition + 1)
                end
            end, descriptionText:GetName() .. ".OnKeyDown")

  3. #3
    Soulwalker
    Join Date
    Sep 2011
    Posts
    19

    Default

    I guess the third argument provides the keycode, also thanks for the snippet! I'll check out BiSCal too.
    Last edited by xiankai; 08-01-2014 at 11:36 PM.

  4. #4
    RIFT Community Ambassador the_real_seebs's Avatar
    Join Date
    Jan 2011
    Posts
    16,859

    Default

    To some extent, the answer is: You don't, really, because the RiftTextfield stuff isn't very complete and has a number of limitations. It may some day get fixed.
    You can play WoW in any MMO. You don't have to play WoW in RIFT. Oh, and no, RIFT is not a WoW clone. Not having fun any more? Learn to play, noob! I don't speak for Riftui, but I moderate stuff there. Just came back? Welcome back! Here's what's changed. (Updated for 2.5!)

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts