5/8/2023 0 Comments Xojo for loopHow do I know if two (or more) ImageWells (or other objects for that matter) have Remain as they are since they are not CheckBoxes. If the control IsAĬheckBox then we will "uncheck" it. The following For.Next loop looks at all of the controls. This can be a big problem, but we can get Xojo to look atĮach control and select it based on, for example, the type of control. The problem for us is to know which number toĬheck. Self.Control(x), where x is the number of the control you want.Ĭomputers keep track of things by numbers: the first control added is 0, the To look at any particular control on the window you may check Xojo keeps track of the number of controls added in It keeps track of this information in a placeĬalled Self.Control, which is a list of the objects. Xojo keeps track of each object (button, text field, label, etc.) You could add codeįor each of the objects individually, but there may be an easier way. Several objects to an original colour, value or location. How do I change a large number of the same type of This code will probably go in a button, timer, etc. If you want numbers from 1, 2.,n use (1, n). You will have to adjust the number range to match your The numbers will be random you can't tell what number The first line picks an integer from 1 to 22. Step 4: Get values for the variables: NOTE: add App. Step 3: Set up variables for the random numbers:Īgain, this code could go in a button, at the top of the form, or in the App window as it best fits your project. Step 2: Set up rndGenerator to select random numbers.Īdd this line of code to the Open Event of the App (if you used the App for Step 1) OR the Open Event of the Window Note the 3 letter start to the name (rnd): Step 1: Create one in Xojo as a property of the App OR the Window. This control does not appear in the Library and does not appear on your window, but you may use it as indicated below. The random number control is call Random. Normally we want random number to fall within a certain range of numbers.įor example, with rolling a die, we want a number from 1 to 6. ThisĬontrol is used differently than the controls we are use to (TextArea, Xojo has a special control that will get random numbers for you. Is there another way to get a random number? This code has the Timer check to see if one of the arrow keys is pressed every 10ms. Let me know if you have a question,įor the settings for the Timer, the following behaviours may work for you. The code uses a Keyboard method that looks for one of the fourĪrrow keys and changes the location of the ImageWell in response. The Timer's Action event code is shown below. The code below lets the user move an ImageWell,Ĭleverly called "ImageWell1," around a windowīy responding to activity on the keyboard. (Of course, you can also check for other keys. Xojo suggests that you put the code into the Action event of a Timer to react if any of these keys have been pressed. Generally you wish to look for the user pressing one of the four arrow keys.Īs with all things on computers, a key's "letter" is translated into a number for the computer use. This sample code is derived from the xojo page: You DO NOT add it from the Library it automatically added to your project! Keyboard.Your ordinary keys generate an event that is recorded by the "built in" Keyboard object. One of the things students seem to want toĭo rather often involves writing some code to respond to the user typing keys on the PLEASE AVOID THIS!įound on this page which will open in a new window. MAY RESULT IN YOU RECEIVING ZERO ON THE PROGRAMME. Must understand the code and be able to explain it to your teacher. If you use any code from another source you the web address) in the comments just before the code. (website, another programmer, etc.) you must: If you want to use any code from another source classmate, sibling, friend, tutor, parent or anyone What if I find some useful code on another website or askĪnother programmer (e.g.
0 Comments
Leave a Reply. |