![]() Open the script editor for the stack and add the following handler, this launches the main stack. You can add a "Starting Up" message if you like. This stack shouldn't be seen but we will set the background color to black in case it is seen while the main stack is launching. To create a launcher stack we create another iPad sized stack, name it Stock Launcher and set the label to Stock Management. # This tells us the direction of the movement if tStart is not empty and tEnd is not empty then if tStart > tEnd and tStart - tEnd > 100 thenĮnd if end if put empty into sCoordinateArray # Compare the x coordinates of the start and end point If sCoordinateArray is empty then put x into sCoordinateArray # When the user touches the screen put empty into sCoordinateArray These commands are handled on the stack script on touchStart pID By recording the start and end points of the touch and calulating how far the user has swiped, and it what direction you can detect and handle swipe gestures. LiveCode provides touchStart, touchEnd and touchMove messages allowing you to detect swipe gestures. We want to be able to move between records by swiping left or right and moving through the items accordingly. If tCurrentCard < tNumberOfEntries then visual effect push left go to the next card else if tCurrentCard = tNumberOfEntries then # Go to the first card visual effect push left go to the first card end if Put the number of cards of this stack into tNumberOfEntries # If the current card is not the last card go to the next card # If the current card is the last card circle to the first card put the number of this card into tCurrentCard Placing it on the stack script makes it accessible to all the buttons and cards of the stack on moveForward The following handler is on the stack script, along with the equivalent moveBack handler. This effect can be achieved using the command When moving forwards through the items the old item should slide off the left hand side, when moving backwards the old item should slide off the right hand side. As this is an iPad app we want to use a sliding movement to move between records. Once there is more that one item in the application we need to be able to move between them. Select after field "name" of group "controls" of tNewCard # Put the cursor in the name field focus on field "name" of group "controls" of tNewCard # Go to the new card using a visual effect visual effect push left go to tNewCard Set the text of image "stock image" of tNewCard to empty # Put the initial text into the fields send "resetControls" to group "controls" of tNewCard # We need to create an image separately on the new card as image data is shared copy image "stock image" of card 1 to tNewCard # Add a new card # This will create a new card with the controls group on it create card # The long name is a unique identifier put the long name of it into tNewCard The newEntry handler is on the stack script, which can be opened from the Object menu on newEntry Select the New button, open the script editor and set the script of the button to on mouseUp ![]() Now that we have created our background we need to script the New button to create a new card and create an image area. This will only work on an iOS device so we will test in in the simulator later, and then on a device. end if # The new image will be the "last" image # We get the text of it, set the text of the stock image and then delete the "last" image set the text of me to the text of the last image of this card delete the last image of this card ![]() MobilePickPhoto "library" if the result is empty then # If the result is empty you know the user has chosen an image and you can start working with it. # When mobilePickPhoto is used the new, chosen image is placed onto the stack # we want it to appear in the image area # and not resize set the rect of the templateImage to the rect of me set the lockLoc of the templateImage to true Using the Edit tool(1) select the image control (2), open the script editor (3) and set the script of the image (4) to on mouseUp In this case we want the user to select in image from their library so we use the command mobilePickPhoto "library" The command "mobilePickPhoto" takes a single parameter that defines what type of choice to use, once the user has chosen an image the selected image appears on the stack and can be manipulated. It is simple enough to use fields to enter text data but what do we do about selecting an image? For this task we will use the mobilePickPhoto command.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |