+ Reply to Thread
Page 4 of 4 FirstFirst 1 2 3 4
Results 46 to 57 of 57
Like Tree1Likes

  Click here to go to the first Rift Team post in this thread.   Thread: Event API Redesign

  1. #46
    Telaran
    Join Date
    Jun 2011
    Posts
    82

    Default

    Quote Originally Posted by ZorbaTHut View Post
    At the absolute earliest, 2.2 for the new features to show up.
    Will there be any new additions of any type in 2.1 or just mainly bug fixes API wise? (a bit off the trail but since it was mentioned..... =P)

  2. #47
    Telaran
    Join Date
    Dec 2012
    Posts
    77

    Default

    Attempting to add this code to a frame:

    _ret.Button:EventAttach(Event.UI.Input.Mouse.Move, MouseMove, "Sandbox.MouseMove")

    and it throws an error stating the event is nil. I then confirmed that with the following:

    dump(Event.UI.Input.Mouse.Move)

    And it too returned nil.

    Any suggestions?

  3. #48
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    Quote Originally Posted by Gralli View Post
    Attempting to add this code to a frame:

    _ret.Button:EventAttach(Event.UI.Input.Mouse.Move, MouseMove, "Sandbox.MouseMove")

    and it throws an error stating the event is nil. I then confirmed that with the following:

    dump(Event.UI.Input.Mouse.Move)

    And it too returned nil.

    Any suggestions?
    Try this one instead:

    button:EventAttach(Event.UI.Input.Mouse.Cursor.Mov e, function(self, h) ... end, "cursor move"
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

  4. #49
    Rift Disciple
    Join Date
    Jan 2011
    Posts
    147

    Default

    Is there a function like Utility.Event.Create() for custom addon frame events? If not, what is the expected structure of the table that should be added to Event.UI.MyAddon.MyEvent?

  5. #50
    Rift Disciple
    Join Date
    Jan 2011
    Posts
    147

    Default

    In answer to my own question, it looks like I can use Utility.Event.Create() to create custom frame events, since there doesn't appear to be anything special about frame events except where they're registered in the Event.UI hierarchy.

  6. #51
    Rift Disciple
    Join Date
    Jan 2011
    Posts
    147

    Default

    I'm getting an error trying to attach a handler for a custom frame event. I've registered the custom frame event like so:

    Code:
    local FireItemClick, ItemClickHandle = Utility.Event.Create("LibSimpleWidgets", "SimpleList.Item.Click")
    I'm attaching a handler function on a specific frame for this event like so:

    Code:
    SWT_Window.list:EventAttach(Event.LibSimpleWidgets.SimpleList.Item.Click, itemClickFn, "ItemClick")
    And it causes this error when the above line of code executes:

    Code:
    Error: Incorrect function usage.
      Parameters: (Frame: SimpleWidgetsTest.SWT_TestList.0x1fb61d98), (table: ), (function: ), "ItemClick"
      Parameter types: Frame, eventGlobal, function, string
    Function documentation:
    	Attaches an event handler to an event.
    	Not permitted on a frame with "restricted" SecureMode while the addon environment is secured.
    		Layout:EventAttach(handle, callbackOrMacro, label)   -- eventFrame, function/string, string
    		Layout:EventAttach(handle, callbackOrMacro, label, priority)   -- eventFrame, function/string, string, number
    Parameters:
    		callbackOrMacro:	A global event handler function. This will be called when the event fires. The first parameter will be the standard frame event handle, any other parameters will follow that.
    		handle:	A handle to a frame event, usually pulled out of the "Event.UI." hierarchy.
    		label:	Human-readable label used to identify the handler in error reports, performance reports, and for later detaching.
    		priority:	Priority of the event handler. Higher numbers trigger first.
        In SimpleWidgetsTest / Slash command for testing widgets, event Event.Slash.swt
    stack traceback:
    	[C]: in function 'EventAttach'
    	SimpleWidgetsTest/main.lua:143: in function <SimpleWidgetsTest/main.lua:9>
    What's wrong here? It looks like it's not recognizing the event handle...

  7. #52
    Shield of Telara Adelea's Avatar
    Join Date
    Mar 2011
    Posts
    734

    Default

    The only thing I can think of, is that there is a disconnect between the creation and use of the event.

    In my libZoneChange, I do:

    Code:
    LZ.handle, Library.libZoneChange.Player = Utility.Event.Create(addon.identifier, "Player")
    LZ.handle is called with whatever parameters are needed for the event.

    Then it gets used in an addon with:

    Code:
    Command.Event.Attach(Library.libZoneChange.Player, RX.Event_libZoneChange_Player, "Library.LibZoneChange.Player")
    Now, admittedly this isnt using UI hooks - but I would think it would work in the same way.

    In your code, your event handler is stored in ItemClickHandle.

    In your snippet, you dont ever put ItemClickHandle anywhere into the Event hierarchy, so there is no mapping from ItemClickHandle to Event.LibSimpleWidgets.SimpleList.Item.Click
    http://forums.riftgame.com/image.php?type=sigpic&userid=125779&dateline=13553  38065

  8.   This is the last Rift Team post in this thread.   #53
    Rift Team
    Join Date
    Oct 2010
    Posts
    927

    Default

    Quote Originally Posted by dOxxx View Post
    In answer to my own question, it looks like I can use Utility.Event.Create() to create custom frame events, since there doesn't appear to be anything special about frame events except where they're registered in the Event.UI hierarchy.
    Quote Originally Posted by dOxxx View Post
    I'm getting an error trying to attach a handler for a custom frame event.
    Sadly, you've now noticed that there is a difference between frame events and global events

    In theory it is definitely possible to allow creation of custom frame events. I haven't written the code for it yet, however.

  9. #54
    Rift Disciple
    Join Date
    Jan 2011
    Posts
    147

    Default

    Quote Originally Posted by ZorbaTHut View Post
    Sadly, you've now noticed that there is a difference between frame events and global events

    In theory it is definitely possible to allow creation of custom frame events. I haven't written the code for it yet, however.
    Curses! I hope this goes in before the old style frame events is removed. I would very much like to have a consistent event handling scheme for my widget library.

  10. #55
    Rift Disciple
    Join Date
    Jan 2011
    Posts
    147

    Default

    Quote Originally Posted by Adelea View Post
    In your snippet, you dont ever put ItemClickHandle anywhere into the Event hierarchy, so there is no mapping from ItemClickHandle to Event.LibSimpleWidgets.SimpleList.Item.Click
    The Utility.Event.Create() function does that automatically.

  11. #56
    Soulwalker
    Join Date
    Jun 2013
    Posts
    3

    Default

    Will be there anything about crafting in this redesigned API?

    I mean, something like available recipes, actual profession levels, etc.

    Thanks!

  12. #57
    General of Telara
    Join Date
    Mar 2014
    Posts
    942

    Default

    *necro alert*

    Okay there's something I just don't get...from this:
    Quote Originally Posted by ZorbaTHut View Post
    So, assuming a hierarchy of UIParent->context->container->target, the following events will trigger, in order:
    Code:
    (User left-clicks on "target")
    UIParent:Event.UI.Input.Mouse.Left.Click.Dive
    context:Event.UI.Input.Mouse.Left.Click.Dive
    container:Event.UI.Input.Mouse.Left.Click.Dive
    target:Event.UI.Input.Mouse.Left.Click.Dive
    target:Event.UI.Input.Mouse.Left.Click
    target:Event.UI.Input.Mouse.Left.Click.Bubble
    container:Event.UI.Input.Mouse.Left.Click.Bubble
    context:Event.UI.Input.Mouse.Left.Click.Bubble
    UIParent:Event.UI.Input.Mouse.Left.Click.Bubble
    I understood that that the callback attached to e.g. container would actually be called with "self" as first argument. Say I did this:
    Code:
    function container.KeyDiveCallback(self, hEvent, key) print(key) end
    container:EventAttach(Event.UI.Input.Key.Up.Dive, container.KeyDiveCallback, "foo")
    Then I would expect Rift to actually call container:KeyDiveCallback(someEvent, someKey), or written more explicitly:
    container.KeyDiveCallback(container, someEvent, someKey).
    BUT, what it appears to do is call
    container.KeyDiveCallback(target, someEvent, someKey).
    That kind of makes the handleEventFrame:GetTarget() method pointless too, since it in fact is identical to the first parameter of the callback. And it totally ruins what I just attempted to do...

+ Reply to Thread
Page 4 of 4 FirstFirst 1 2 3 4

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