Skip to content

Commit

Permalink
KeyEvent() constructor now can also take a code and a modifier (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
fxliang authored Mar 8, 2024
1 parent 7404699 commit 20ddea9
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -508,12 +508,20 @@ namespace KeyEventReg {
return t.modifier();
}

an<T> make(const string &key) {
return New<T>(key) ;
int raw_make(lua_State *L) {
an<T> res;
int n = lua_gettop(L);
if (n == 1)
res = New<T>( string(lua_tostring(L, 1)) );
else if (n > 1)
res = New<T>( lua_tointeger(L, 1), lua_tointeger(L, 2) );

LuaType<an<T>>::pushdata(L, res);
return 1;
}

static const luaL_Reg funcs[] = {
{ "KeyEvent", WRAP(make) },
{ "KeyEvent", raw_make },
{ NULL, NULL },
};

Expand Down

0 comments on commit 20ddea9

Please sign in to comment.