The following function is meant to assign key values to my game. The problem is in the waiting for a key press. My logic was to click the key that represents the button your wish to map. The label then changes to a waiting message and the program halts until a key is pressed. When a key is pressed it should re label the label with the new key code.
Function request_controls() ' create a window Local ControlWindow:TGadget = CreateWindow("Key Editor", 232, 232, 320, 240) Local gup_button:TGadget = CreateButton("Up Key", 16, 16, 64, 16, ControlWindow) Local gup_tag:TGadget = CreateLabel("Key " + String(up_button), 96, 16, 200, 16, ControlWindow) Local gdown_button:TGadget = CreateButton("Down Key", 16, 32, 64, 16, ControlWindow) Local gdown_tag:TGadget = CreateLabel("Key " + String(down_button), 96, 32, 200, 16, ControlWindow) Local gleft_button:TGadget = CreateButton("Left Key", 16, 48, 64, 16, ControlWindow) Local gleft_tag:TGadget = CreateLabel("Key " + String(left_button), 96, 48, 200, 16, ControlWindow) Local gright_button:TGadget = CreateButton("Right Key", 16, 64, 64, 16, ControlWindow) Local gright_tag:TGadget = CreateLabel("Key " + String(right_button), 96, 64, 200, 16, ControlWindow) Local gkey1_button:TGadget = CreateButton("Key 1 Key", 16, 80, 64, 16, ControlWindow) Local gkey1_tag:TGadget = CreateLabel("Key " + String(button_1), 96, 80, 200, 16, ControlWindow) Local gkey2_button:TGadget = CreateButton("Key 2 Key", 16, 96, 64, 16, ControlWindow) Local gkey2_tag:TGadget = CreateLabel("Key " + String(button_2), 96, 96, 200, 16, ControlWindow) Local set_button:TGadget = CreateButton("Set Current", 16, 128, 64, 16, ControlWindow) Local cancel_button:TGadget = CreateButton("Cancel", 16, 128 + 16, 64, 16, ControlWindow) Repeat WaitEvent() ' choose the event that tripped the wait event Select EventID() Case EVENT_WINDOWCLOSE ControlWindow.Free() Return End Select Select EventSource() Case gup_button gup_tag.SetText("Waiting, press key for 'up'") up_button=WaitChar() gup_tag.SetText("Key " + String(up_button)) End Select Forever End Function