Skip to content

Commit

Permalink
Merge branch 'mouse-presses' of github.com:keharriso/love-nuklear
Browse files Browse the repository at this point in the history
  • Loading branch information
keharriso committed Jan 3, 2019
2 parents de05b25 + 8d081e5 commit 2fd70e6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ function love.keyreleased(key, scancode)
ui:keyreleased(key, scancode)
end

function love.mousepressed(x, y, button, istouch)
ui:mousepressed(x, y, button, istouch)
function love.mousepressed(x, y, button, istouch, presses)
ui:mousepressed(x, y, button, istouch, presses)
end

function love.mousereleased(x, y, button, istouch)
ui:mousereleased(x, y, button, istouch)
function love.mousereleased(x, y, button, istouch, presses)
ui:mousereleased(x, y, button, istouch, presses)
end

function love.mousemoved(x, y, dx, dy, istouch)
Expand Down
8 changes: 4 additions & 4 deletions example/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ function love.keyreleased(key, scancode)
input('keyreleased', key, scancode)
end

function love.mousepressed(x, y, button, istouch)
input('mousepressed', x, y, button, istouch)
function love.mousepressed(x, y, button, istouch, presses)
input('mousepressed', x, y, button, istouch, presses)
end

function love.mousereleased(x, y, button, istouch)
input('mousereleased', x, y, button, istouch)
function love.mousereleased(x, y, button, istouch, presses)
input('mousereleased', x, y, button, istouch, presses)
end

function love.mousemoved(x, y, dx, dy, istouch)
Expand Down
12 changes: 7 additions & 5 deletions src/nuklear_love.c
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ static int nk_love_keyevent(struct nk_context *ctx, const char *key,
}

static int nk_love_clickevent(struct nk_love_context *ctx, int x, int y,
int button, int istouch, int down)
int button, int istouch, int presses, int down)
{
nk_love_transform(ctx->Ti, &x, &y);
struct nk_context *nkctx = &ctx->nkctx;
Expand Down Expand Up @@ -1161,26 +1161,28 @@ static int nk_love_keyreleased(lua_State *L)

static int nk_love_mousepressed(lua_State *L)
{
nk_love_assert_argc(lua_gettop(L) == 5);
nk_love_assert_argc(lua_gettop(L) == 5 || lua_gettop(L) == 6);
struct nk_love_context *ctx = nk_love_checkcontext(1);
int x = luaL_checkint(L, 2);
int y = luaL_checkint(L, 3);
int button = luaL_checkint(L, 4);
int istouch = nk_love_checkboolean(L, 5);
int consume = nk_love_clickevent(ctx, x, y, button, istouch, 1);
int presses = lua_gettop(L) == 6 ? luaL_checkint(L, 6) : 1;
int consume = nk_love_clickevent(ctx, x, y, button, istouch, presses, 1);
lua_pushboolean(L, consume);
return 1;
}

static int nk_love_mousereleased(lua_State *L)
{
nk_love_assert_argc(lua_gettop(L) == 5);
nk_love_assert_argc(lua_gettop(L) == 5 || lua_gettop(L) == 6);
struct nk_love_context *ctx = nk_love_checkcontext(1);
int x = luaL_checkint(L, 2);
int y = luaL_checkint(L, 3);
int button = luaL_checkint(L, 4);
int istouch = nk_love_checkboolean(L, 5);
int consume = nk_love_clickevent(ctx, x, y, button, istouch, 0);
int presses = lua_gettop(L) == 6 ? luaL_checkint(L, 6) : 1;
int consume = nk_love_clickevent(ctx, x, y, button, istouch, presses, 0);
lua_pushboolean(L, consume);
return 1;
}
Expand Down

0 comments on commit 2fd70e6

Please sign in to comment.