How do I pass variables through a button click event handler and make changes to the button within the subroutine it's been passed to in visual basic? - forms

I'm trying to make a minesweeper game using visual basic forms. I have made the tiles by making each one a separate button. I have made an array of Boolean values to decide which buttons have mines. I am stuck because I can't figure out how to pass variables through the event handler. I also don't know how to make changes to the button within the subroutine that is called with the button click event handler.
I would appreciate any help anyone can offer.
Thanks a lot!

Related

Unity Add Shooting Controller - easy one

I am very new to unity, and still learning how to create games and edit scripts, so this will probably be easy for anyone to answer. I don't really know what you want to see.
I have a script for using the left mouse button to fire. I want to add one for the right mouse button.
What I've done:
I copied the script that calls the objects and changed the name to Fires.
I added the controller button
I copied the same lines for Fire (original) in the Input manager script. changed the names to Fires.
The problem: pressing right mouse button doesn't do anything. If I use the Input Manager to call Fires, it works, but not when I press the button. I'm missing something, but I'm not sure what.
Any help would be appreciated.

Stop program until user clicks button

In my main program, I create a JFrame with a button on it. This acts as a separate dialog box that prompts the user for information. What I would like, is when the dialog box appears, is for the program to stop running until the user clicks the button.
If I just create the JFrame normally, the program will move on in the code and do other statements before information is received from the dialog box. This is an issue, because later on in the code another JFrame is created using information from the first.
Separate out the logic of displaying the frame from actions that happen after the button is pushed. What I mean is you should add an Action Listener to the Button you have, and put the code inside the its method instead of the main program. The problem is you are visualizing the solution in a procedural oriented way. Think Object Oriented.

Accessing forms created through LWUIT resource editor using code

I am trying to develop a quiz application using LWUIT resource editor and am having great difficulty.
I have created two Forms 'GUI1' and 'GUI2' .
GUI1 displays the following:
A question(in the form of a TextField)
5 RadioButtons belonging to the same group
A Button which says 'OK'
GUI2 displays the following:
A TextField
A Button to go back to GUI1
Now the problem is:
Initially GUI1 is displayed. When the user chooses a RadioButton , I wish to know which RadioButton was selected. If that RadioButton was indeed the correct answer, then when the user clicks on the 'OK' Button on GUI1, I wish to display the text 'correct' in the TextField on GUI2 and then display the GUI2.
If the user chose the wrong answer, then I wish to display the text "Wrong" in the TextField on GUI2 and then display the GUI2.
How can this be done with resource editor? I am very foxed. Please help.
I wish to refer to the TextField on GUI2 when I am currently on GUI1. How can this be done with resource editor? Writing a manual code for all this would be very time consuming.
Ok I will try to explain the best I can.
When you design the first Form GUI1 the five RadioButtons must be in the same group. I don't know how to do that in the resource editor (I think there is a field called ButtonGroup in the RadioButton, but I can't remeber). What I would do is take the five RadioButton by code in the before method of GUI1 and add them to a ButtonGroup element.
With ButtonGroup you can know which element is selected using ButtonGroup.setSelectedIndex(). When you press the Button take this value and act as appropriate to the situation.
If you don't understand anything please tell me and I will try to help you.
Is not a hard thing to do. There must be a way to do it with the Resoruce editor but at the moment I donĀ“t know how.
As Shai mentioned, the best thing to do is to use listeners to set the "state" of the buttons on clicking them and when you move to the next form you just retrieve the state of the previous text field.
Manual code may actually be faster for you, do most of the UI in the resource editor and transfer to a form that is written manually. That way you have full control over your objects and transfer back into the GUI builder form when needed.

Determining If Left- or Right- Click

In FileMaker Pro, it is easy to override a field's button setup so that a script is run when the field is clicked on. Is there a way from within such a script to determine if the user left-clicked or right-clicked?
Thanks,
Ben
Oddly, I am pretty sure you can't get the mouse button clicked. If you could, it would probably be a Get() function.
I tested:
Get(ActiveModifierKeys)
and
Get(TriggerModifierKeys)
but neither return a value for mouse clicks, only keyboard clicks.
If you are a C++ programmer, you could write a plugin that creates a new FileMaker function that returns the mouse button clicked, but you would need to install the plugin on every machine that will use the function.

Listener function for gwt widgets

For my project when a button is clicked, the click event should then wait and listen to the next two clicks on different widgets and then connect them so as to form relationship between them.
Right now i an trying to use FocusListener without success. Any suggestion will be of great help.
Thank you.
I would think you'd just want an ClickListener for each object. Handle "enabling" the other two objects in the first object's click event, then when those two objects are clicked on, invoke the method to form the relationship. You don't want to wait in the first object's event handler.