Keyslam / Inky

A GUI Framework for LÖVE
MIT License
48 stars 4 forks source link

Target mode broken? #11

Closed lakotajames closed 8 months ago

lakotajames commented 1 year ago

I'm not sure if I'm just misunderstanding, but I've got code that looks like this:

pointer:setTarget{actions[1]}
print (pointer:getMode())

This prints "POSITION".

Lines 85 - 94 of core/pointer/internal.lua read as follows:

    if (self._target ~= target) then
        return self
    end

    self._target = target
    self._mode = PointerMode.TARGET

    self._scene:__getInternal():onPointerTargetChanged(self._pointer)

    return self

If I'm reading that right, it seems like the problem is that the if statement is backwards. Replacing the ~= with == on line 85 causes this error:

Error

lib/Inky/inky/core/pointer/internal.lua:244: attempt to call method '__getInternal' (a nil value)

Traceback

[love "callbacks.lua"]:228: in function 'handler'
lib/Inky/inky/core/pointer/internal.lua:244: in function 'setOverlappingElements'
lib/Inky/inky/core/scene/internal.lua:108: in function '_resolvePointerOverlappingElements'
lib/Inky/inky/core/scene/internal.lua:132: in function 'onPointerTargetChanged'
lib/Inky/inky/core/pointer/internal.lua:92: in function 'setTarget'
lib/Inky/inky/core/pointer/init.lua:54: in function 'setTarget'
ui/actionbar.lua:17: in function '_initializer'
lib/Inky/inky/core/element/internal.lua:312: in function 'initialize'
lib/Inky/inky/core/scene/internal.lua:199: in function 'render'
lib/Inky/inky/core/element/internal.lua:323: in function 'render'
lib/Inky/inky/core/element/init.lua:159: in function 'render'
main.lua:105: in function 'draw'
[love "callbacks.lua"]:168: in function <[love "callbacks.lua"]:144>
[C]: in function 'xpcall'

Which is beyond my ability to troubleshoot.

Keyslam commented 8 months ago

Sorry for the late response. This has been fixed in the latest version.