Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String.fromCharCode() #19

Closed
CerfurMark opened this issue Jun 14, 2014 · 3 comments
Closed

String.fromCharCode() #19

CerfurMark opened this issue Jun 14, 2014 · 3 comments
Labels

Comments

@CerfurMark
Copy link

Hello,

I am trying to use String.fromCharCode(keyCode) from the DOMAPI. The following code seems to work:

local s = window.String.new("abc")
print(s:charCodeAt(1))

98

But String.fromCharCode() is a static global and my attempts at calling this function have all failed:
window.String.fromCharCode(65) -> Attempt to call non-function
window.String:fromCharCode(65) -> Attempt to call non-function
window.extract() String.fromCharCode(65) -> Attempt to call non-function
window.extract() String:fromCharCode(65) -> Attempt to call non-function
window.String.fromCharCode(window.String, 65) -> Attempt to call non-function

Can you help me out?

Thank you.

@CerfurMark
Copy link
Author

Update: The Lua code string.char(65) seems like it will work for my purposes, but I'm still hoping to learn how to call String.fromCharCode(65).

@paulcuth
Copy link
Contributor

Hi,

Cheers for this. You're right, it is a bug. I'll look into a fix and get back to you tomorrow.

Paul.

@paulcuth paulcuth added the bug label Jun 16, 2014
@paulcuth
Copy link
Contributor

It wasn't adding static methods to constructor functions. This has now been fixed in 1ee194a.

As fromCharCode() is a static method, the best way to use it would be:

String.fromCharCode(65)

As I'm sure you're aware, string.char(65) was working because it's part of the Lua standard library in the VM and not part of the DOMAPI extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants