How to move a box on screen

Hello

I just started to develop in the Cascades and spent the afternoon by downloading samples and by reading the documentation. My question is about the simple example of Cascades ' Hello world '. Namely, I tried to combine it with a gesture touch, but I can not understand how to operate correctly. The idea is the following: tap on the bubble, and then slip around or tapping the screen a bubble jumps to the tapped coordinate. I guess the "translationX, translationY" in the notecard body is bad, but I have no idea how fix it.

Thanks in advance,

import bb.cascades 1.0

Page {
    // A container is used to gather visual items together.
    content:Container {

        attachedObjects: [
            // Non UI objects are specified as attached objects
            ImagePaintDefinition {
                id: backgroundPaint
                imageSource: "asset:///images/background.png"
            }
        ]
        layout: DockLayout {
        }

        background: backgroundPaint.imagePaint

        // The container containing the bubble image and text
        Container {
             id: movingBubble
             horizontalAlignment: HorizontalAlignment.Center
             verticalAlignment: VerticalAlignment.Center
             layout: DockLayout {
             } 

            // The bubble image
             ImageView {
                  imageSource: "asset:///images/bubble.png"
             }

             // A text label with the comforting hello world text
             Label {
                text: qsTr("Hello World") + Retranslate.onLanguageChanged

                // The Label text style.
                textStyle.base: SystemDefaults.TextStyles.BigText
                textStyle.fontWeight: FontWeight.Bold
                textStyle.color: Color.create("#ff5D5D5D")

                // Center the text in the container.
                verticalAlignment: VerticalAlignment.Center
                horizontalAlignment: HorizontalAlignment.Center
            }// Label

        }// Container

        onTouch: {
            movingBubble.translationX = event.localX - (movingBubble.preferredWidth / 2);
            movingBubble.translationY = event.localY - (movingBubble.preferredHeight / 2);
        }
    }// Container
}// Page

Other code, for when you do not have a width/height preferred;

       Container {
            id: movingBubble
            property int lastY;
            property int lastX;

Snip

        onTouch: {
            if (event.isDown()) {
                movingBubble.lastX = event.localX;
                movingBubble.lastY = event.localY;
            } else if (event.isMove()) {
                movingBubble.translationX += event.localX - movingBubble.lastX;
                movingBubble.translationY += event.localY - movingBubble.lastY;
                movingBubble.lastX = event.localX;
                movingBubble.lastY = event.localY;
            }
        }

Tags: BlackBerry Developers

Similar Questions

  • How to move text on the screen?

    I can type the text in the little boxes when place the text on the screen (not the titles developed - just place the text on the screen after hitting the "T" key).  The box is difficult to work, and I did not understand how simply MOVE it to a different area of the screen.  Is this possible?  I can't just click and drag it.  And why the cursor looks like this little arrow pointing to?  And why the box to keep changing shape on me, etc.. ?  Someone else has a lot of trouble with this?

    Here is a glance at the Titler Panel, with one selected area of text (visible Bounding Box) and ready to be moved. Pre 4.0 it's with but a few exceptions, will look the same.

    Hope that helps and good luck,

    Hunt

  • How to move from PopupScreen to screen settings.

    Hi all.

    I have a MyScreen extends screen with a button to display PopupScreen. In PopupScreen, I have the list RadioButtonFields, OK and Cancel buttons. When I click the OK button, the RadioButtonField value will switch to MyScreen but now I don't know how to implement it.

    Please help me.

    Thank you

    Yes, thank you peter_strange. The problem will be resolved if we use the internal class. The MyPopupScreen is an inner class within the MyScreen.

  • BlackBerry Q10 Q10-how to move icons

    Please tell me how to move icons from one screen to another screen.  I tried to put them on the side, but they steal everything right back.  I hit the until they start pulsating and they don't always move.  I don't know what to do.

    Thank you very much

    Just as you describe, pulsing touch and move an icon ON the right or to the left of the Panel you are currently in UNTIL you see that you are this new Panel, and release.

  • When we turn on my wife's ipad, a box of red line begins to jump around the screen, and then a pale red stripe moves back on the screen. Any ideas on how to stop it? Thank you

    When we turn on my wife's ipad, a box of red line begins to jump around the screen, and then a pale red stripe moves back on the screen. Any ideas on how to stop it? Thank you

    The standard specifies:

    -Reset the device iOS. Nothing will be lost

    Device iOS Reset: Hold down the On / Off button and the Home button at the same time for to

    ten seconds, until the Apple logo appears.

    -Reset all settings

    Go to settings > general > Reset and tap reset all settings.

    All your preferences and settings are reset. Information (such as your contacts and calendars) and media (such as songs and videos) are not affected.

    -Restore from backup. See:

    Restore your device from an iCloud or iTunes backup - Apple Support

    -Restore factory settings/new iOS device.

    If still problem, make an appointment at an Apple store Genius Bar because it appears that you have a hardware problem.

    Shop Apple Store - Genius Bar

  • How to move from one screen to the other applications?

    In order to organize some screens after installing several applications, how can we move them from one screen to the other?
    I found it possible to place them in the bottom bar and then replace them in the necessary form, but it is very slow...
    Another way?

    Also, is it possible to place the apps where we want to and not automatically bring reorganized (empty filled)?
    Thank you

    DUPE: https://support.mozilla.org/en-US/forums/firefox-os-english-forum/709563

  • How to move the "blue bar" with the start option and the clock and icons of a vertical__position on the left side of the screen to the bottom of the screen... has this before happen__once, can't remember what to do.

    How can I move the 'blue bar' with the start option and the clock and icons on the left side of the screen to the bottom of the screen.  It's happened before and I forgot how to move.

    Hello pookprec

    Here's how to do it

    .

  • How to move the top of the screen (active form)

    Hi all

    How to move the top of the screen (active form),

    Suppose I have 5 screens in the battery, I want to make the screen at the bottom of the stack as Active (top screen) without pushing and poping

    Of the display is a battery.  To move round on screens requires push and pop, as it would to move items in a stack.  Sorry, if you want to see the screen that currently is the bottom of the stack, then you either have everything that is above him, the pop or pop and push up.

    But here, we are talking about instances of the screen, not the specific screen class.  To understand the difference here is an example.

    I have two screens in my application, a list screen and a detail screen.  My application starts with the list screen.  The user selects an item (X) and displays details on the subject using the details screen.  While displaying the detail, the user decides that he wants to see a different list.  So, we start a new instance of the list screen, showing a different list.  Then, the user decides to view some details of one of the items on the list (Y) and if the application displays a new instance of the details screen.

    So now that the user has 4 screens on the display stack.  The top of the screen is a detail showing the item detail screen, the screen below is an example of the display of the list, the screen under that is another detail screen, showing the point X this time, and under that is a list screen.

    Does that help?

  • Smartphones blackBerry how to move an application icon to the home screen

    How to move an application icon in the menu of the applications to the home screen.

    For example the browser icon?

    domdp wrote:

    ... I have the selected theme and I get 10 icons along the left side and bottom...

    ... I think I may be limited to 10 icons...

    Witch hunt... But in reality its limited to 9 icons in the theme of the profiles icon is still present. From this screen, press Menu to display the largest list of icons. ARange so the first 9 icons are the ones you want to see on the theme of the.

  • How to make a box for error off my screen. Wrong e-mail address does not pass & I always get error days later

    How to make a box for error off my screen.  Wrong e-mail address does not pass & I always get error days later

    Hello

    Welcome to the Microsoft community. I appreciate your efforts to resolve the issue. I will certainly help you with the problem you are experiencing.

    The description of the problem seems a little unclear and I wish I had a better understanding before you start working on it. I would be grateful if you could help me with more information.

    • You use the Windows 8 Mail or any other email client?
    • When was the last time it was working fine?

    If you encounter problems with Windows Mail app, try the following steps.

    Step 1:

    Please go to the link below, download the file and run it.

    Run applications troubleshooting

    Download and run the troubleshooter modern UI App.

    http://download.Microsoft.com/download/F/2/4/F24D0C03-4181-4E5B-A23B-5C3A6B5974E3/apps.diagcab

    Step 2:

    I suggest to go through the link and follow the given procedure. Here is the link for your reference.
    Solving problems with a soft

    Hope this information was useful.

  • CTRL-Alt-2 moves to the second screen windows - how to disable

    Hello

    I have a new computer to dual screen in Windows 8.  When I do Ctrl + Alt + 2, my current window is moved to the screen 2 (and equivalent to 1).  Does anyone know if it is a shortcut of Windows 8 or another utility?  I have a nVidia graphics card and the 7200LE Panel is not shortcut (besides the stereoscopic 3D features that are disabled).

    The problem is that Windows seems to treat the key ALT GR (right Alt key for the keyboard layout of the French-Canada) as a combination of Ctrl + Alt, then when I press Alt Gr + 2 to type the symbol @, my window also moves to the second screen.  The equivalent problem is when I type the ± symbol (AltGr + 1 gives my character, and move the window), but this isn't as big a problem.

    Anyway, if anyone knows how to disable the Ctrl + Alt + 2 sets of shortcuts, or how to make windows treat differently the keys Ctrl + Alt, AltGr do let me know.

    Thank you
    IM

    I had the same problem, and in my case it was a third-party application that came with a USB to DVI adapter.

    The utility is called "MCTDUtil.exe" and is in "\Program Files".

    It has a visible icon called "Super Utility".  There, you have a menu called "Multi Display Control Panel".  The Ctrl-Alt-1 and Ctrl-Alt-2 are mapped to do exactly this: move the window being displayed 1 and 2 respectively.  You can disable the feature of this Panel.

    I suspect that this utility is not necessary and can be removed.

  • Captivate 7 How have hit (right arrow) to make the simulation to move to the next screen

    I'm building a simulation and need some keystrokes to create the action to move to the next screen.  Example: The user is prompted to press the right arrow key to make the screen to move to the next screen.  I have to be able to set up failure messages when the user presses an invalid key.  I don't know what I should use.  I tried text boxes, but they need to be entered in the text.  Thanks in advance

    CTRL is a combination key... will not work as a shortcut key, even for ALT and SHIFT. System expects another key in combination with these keys.

  • How to move the pulldown workspace Photoshop 2014

    Hello

    I have a pretty simple question, which I am sure has an easy solution, but miss me. One of my colleagues is using photoshop CC 2014 and when she goes to crop a photo the reset buttons, Cancel and Commit pop up, but the check mark (OK button) is actually blocked by menu of the workspace that appears on the right side of the screen.


    Does anyone know how to move the buttons in the toolbar, or move this menu drop-down? She works on a smaller screen, so she has not much real estate to work with and it gets frustrating. It is also important to mention that she is 72 years, so give it a shortcut does not really work, so that the check box.

    Thank you

    Cancel = escape key

    Commit = enter key

  • How to restore the XP Welcome screen

    My X 200 is a machine of a user, so I decided to disable the fast user switching. In the process I inadvertently stops the welcome scree also. When I went to turn it on again, I got a dialog box with a message indicating that a - atginahook.dll - program has disabled the Welcome screen and fast switching. In my view, that this file is part of the fingerprint software. Does anyone have an idea how to get around this time screen weclome and quick-change checkboxes are now greyed out so I can't further at this point... How to restore functionality to the option "change the average user log or disable"?

    Thanks for your comments

    xwray wrote:

    My X 200 is a machine of a user, so I decided to disable the fast user switching. In the process I also inadvertently has disabled the Welcome screen. [snip] Does anyone have an idea how to get around this time screen weclome and quick-change checkboxes are now greyed out so I can't further at this point... How to restore functionality to the option "change the average user log or disable"?

    I did the same thing and had the same problem on my T500 (which includes a fingerprint reader...).

    I fixed it to Client Security Solution (a ThinkVantage program); there I clicked on 'Footprint', then 'manage '. After authentication, I clicked on 'Settings' at the top of the window, then unchecked "Disable Fast User Switching Support. After a reboot, everything was back to normal.

    Hope this helps

  • How to get the Western Digital screen to appear without having seen the image of office as well.

    Original title: WD1TB MY book was installed with Windows XP and the deskyop "bleeds" through parts of the WD Menu. How can I get the WD screen appears without the office showing?

    WD1TB MY Book was installed with Windows XP and office "bleeds" through parts of the WD Menu. How can I get the WD screen appears without the office showing?  I can't read the instructions when this screen appears partially gray with the news of WD and the desktop showing through the other box of WD.

    Hello

    You can try to connect the WD 1 TB My Book on another computer running Windows XP and see if the problem still occurs.

    You can also get in touch with support from WD for assistance on the issue.

    Contact us Support WD

    http://support.wdc.com/contact/index.asp?wdc_lang=en#us

    WD community

    http://community.wdc.com/T5/my-book-for-PC/BD-p/BoardExample

Maybe you are looking for