X
Xenosis
Guest
I am making my own keyboard to draw on the screen
I have an object oKey setup like this
create
letter = "A";
draw
just draws the key however i want
global tap
if (point_in_rectangle(xTouch, yTouch, leftBoundary, topBoundary, rightBoundary, bottomBoundary)) {
show_debug_message(letter + " tapped");
with(oKeyboard) {
event_perform(ev_keypress, ord(letter));
}
}
So this is going to check if the tap is within the boundaries i draw and then emit a key pressed event using the letter to the oKeyboard object
In the oKeyboard object i can lay out my keys however i want by create instances of the oKey object like this
var key = instance_create_layer(x, y, "Instances", oKey)
key.letter = "A";
key = instance_create_layer(x + 22, y, "Instances", oKey)
key.letter = "B";
and then overriding Key Press - A, Key Press B etc i will be able to handle them
This is not quite working as expected though because when i run
event_perform(ev_keypress, ord(letter));
I get a not set before reading it error on the letter variable
if this was set to ord("A") it works but i need it to pass the letter because i only want to create the instances of oKey myself
Anyone know why ord(letter) won't work? the show_debug_message that you see is called so it already has a reference to letter so I'm not sure why it can't use it with ord
I have an object oKey setup like this
create
letter = "A";
draw
just draws the key however i want
global tap
if (point_in_rectangle(xTouch, yTouch, leftBoundary, topBoundary, rightBoundary, bottomBoundary)) {
show_debug_message(letter + " tapped");
with(oKeyboard) {
event_perform(ev_keypress, ord(letter));
}
}
So this is going to check if the tap is within the boundaries i draw and then emit a key pressed event using the letter to the oKeyboard object
In the oKeyboard object i can lay out my keys however i want by create instances of the oKey object like this
var key = instance_create_layer(x, y, "Instances", oKey)
key.letter = "A";
key = instance_create_layer(x + 22, y, "Instances", oKey)
key.letter = "B";
and then overriding Key Press - A, Key Press B etc i will be able to handle them
This is not quite working as expected though because when i run
event_perform(ev_keypress, ord(letter));
I get a not set before reading it error on the letter variable
if this was set to ord("A") it works but i need it to pass the letter because i only want to create the instances of oKey myself
Anyone know why ord(letter) won't work? the show_debug_message that you see is called so it already has a reference to letter so I'm not sure why it can't use it with ord