ID:1157867
 
Keywords: focus, input, macro
I am trying to make a highly modular input/output form system using input and label interface controls, for another project I have in mind.

I have to set the input controls to "Don't use this control for commands" (no-command=true), so that the text stays after the user sends it to the corresponding label. The problem is, I still want to use the "Return" key to send the text, so I made a macro for that, but since the input has focus, I can't get any macros to run!

So basically, what I want to know is, can you create a macro that can somehow bypass the focus of an input and run anyway? This is kind of like what the "Alt" key does, switching focus to the menu, no matter what the current conditions are, but there doesn't seem to be any macro that controls what the "Alt" key does. Is there a way to give a macro the same level of power over the game as the "Alt" key?

I searched the forum up and down, but couldn't really find anything on changing focus via macro. It happens all the time when clicking somewhere else, or if you press "Return" when in an input with no-command set to false, but what if I have no-command set to true or I wanted to use some other key like "Esc" to remove focus?

Anyway, here is the basic code, if it helps explain what I'm trying to do. I had other focus checks in there, but removed them for debugging.
mob
verb
//The RETURN key macro is set to run this verb:
SendText()
send_text("mainwindow.input", "mainwindow.label")

proc
//Return the text from a given interface control:
get_text(control)
return winget(usr, "[control]", "text")

//Set the given interface control with the given text:
set_text(control, text)
winset(usr, "[control]", "text=\"[text]\"")

//Transfer the text from the given input control to the given output control:
send_text(input, output)
var/text = get_text("[input]")
set_text("[output]", text)


Honestly, this is starting to feel like a "Hole in the Bucket" problem. I don't even know if what I'm asking is possible or if I'm just not seeing the answer in plain sight. It could be that I'm just overthinking this whole thing, as is often the case.

I already know how to change focus using winset(), but that probably won't help me if a macro can't call the verb to begin with.

Anyway, I hope someone knows how to solve this problem. It's really bugging me.