How can I move a rectangle with key?

I try to control a rectangle with left and right key to move, but failed and need help to make it work. thanks!
var cx:Number;
var cy:Number;
var fang:Rectangle=Rectangle{
     x:bind cx  y:bind cy
     width:50  height:50
     fill:Color.BLUEVIOLET
     onKeyTyped: function( e: KeyEvent) : Void {
                if(e.code==KeyCode.VK_KP_LEFT){
                         cx++;
                         println("left pressed!");
                if(e.code==KeyCode.VK_KP_RIGHT)
                          cx--;
Stage{
    width:200
    height:400
    scene:Scene{
         content:[fang]
}Edited by: Phoenix2006 on Sep 14, 2009 8:18 PM
Edited by: Phoenix2006 on Sep 14, 2009 8:21 PM

You will have to invoke requestFocus() on Rectangle so as to gain focus. You may try below code..
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
var cx:Number;
var cy:Number;
var fang = Rectangle {
    x:bind cx
    y:bind cy
    width:50
    height:50
    fill:Color.BLUEVIOLET
    onKeyReleased: function(e) : Void {
        if(e.code == KeyCode.VK_LEFT) {
            cx--;
        } else if(e.code == KeyCode.VK_RIGHT) {
            cx++;
        } else if(e.code == KeyCode.VK_UP) {
            cy--;
        } else if(e.code == KeyCode.VK_DOWN) {
            cy++;
Stage{
    width: 200
    height: 400
    scene: Scene {
        content: [ fang ]
fang.requestFocus();

Similar Messages

  • How can i creat several rectangles with one draw rect.vi

    how can i creat several rectangles with one draw rect.vi? thanks
    Solved!
    Go to Solution.

    You can call it in a for loop, with an array of the rectangle coordinates you want to draw. Is this what you mean?
    CLA, LabVIEW Versions 2010-2013
    Attachments:
    rectangle.png ‏11 KB

  • [CS6] How can I move shapes (created with paths)?

    [CS6]
    I created shapes with the pen tool.
    Then I selected the path selection tool and selected a path.
    Clicked right mouse key, choosed "Fill Path..." or "Fill Subpath"
    (don't know what it means). After filling with a color I get an object in
    the form of the path and I can move the path to another place.
    But I can't move the object in the shape of the path.
    I can't move it with "Path selection tool" because it's no path.
    Then I tried the "Move Tool" but I also can't select the object with it
    instead the whole canvas is moving.
    How can I select and move shapes which were
    created with the pen tool?

    You've drawn a Path then filled a region of a pixel layer.
    To make Shape layers, use the Pen Tool in "Shape" mode set in the Options bar.
    If you really do want to draw a Path and use it to create moveable pixel shape then do the fill with an empty layer targeted.

  • When I use my Delete key to delete a song, I get a pop-up.  This is OK, except the Keep File button is defaulted and I cannot tab or arrow to the "Move to Trash" button, and so i need to use my mouse.  How can I do this only with keyboard?

    When using iTunes on my iMac, I use my Delete key to delete a song and I get a pop-up.  This is OK, except the Keep File button is defaulted and I cannot tab or arrow to the "Move to Trash" (or Cancel) button, and so I need to use my mouse.  How can I do this only with keyboard?

    Huh.. Interesting. I went back to check these proceedures and found there is a difference between using the return key or the space bar as the action command.
    tabbing the blue ring moves the selection and then spacebar takes that action. The return key takes action of only the blue collored button.
    .... learn somting new every day, even if it is somthing I previously forgot

  • HT4436 I have now downloaded all of my CD's to my itunes library and have since only purchased new music using itunes Store.  This itunes library is stored on an old Dell Desktop that I am getting ready to replace with an iMac; how can I move the music? 8

    I have now downloaded all of my CD's to my itunes library and have since only purchased new music using itunes Store.  This itunes library is stored on an old Dell Desktop that I am getting ready to replace with an iMac; how can I move the music? 86GB
    Is the music I downloaded from my CD's already in the iCloud or only the music I purchased on itunes?

    This might help: http://www.macworld.com/article/1146958/move_itunes_windows_mac.html.

  • How can I move my PC (Windows 7) iTunes library (with my cps ripped) to my Mac iTunes library?

    Just for my curiosity and knowledge,
    I have a PC (Windows 7) and a Mac (OS X 10.10).
    Both of them with the latest version of iTunes.
    Both of them with the exact music library (genre, artist, album, etc).
    All my music is coming from iTunes Store, so very easy to re download at any time I want with my Apple ID
    My PC (Windows 7) computer has a CD/DVD drive. I would like to RIP some music from my CDs and add them to my PC (Windows 7) iTunes library. 
    Once I finished, how can I move my PC (Windows 7) iTunes library (with my cps ripped) to my Mac iTunes library?
    Thank you so much

    If you've downloaded the media idependently to each library so far then thet won't be exactly the same as there are different naming rules for the files and folders in OS X and Windows. See Make a split library portable for some general advice. You can move a portable library between Mac and Windows, but there is a delay opening the library after each change of OS.
    tt2

  • My PC with iTunes on it got fried (lightning).  I have a 2nd PC with iTunes on it.  How can I move my devices to that iTunes (I have recovered data from the drive)

    I had a primary PC that had iTunes on it that got fried by lightning strike a few months ago.  I have several devices (1 iPod, 1 iPad, 3 iPhones) that were synched with that iTunes install.  I had a secondary PC with a separate iTunes installation on it (separate music library.)  I recovered the hard drive so I can move the music to the secondary PC, but how can I sync my devices with that 2nd installation of iTunes without losing all of the information on those devices?  (I haven't saved or synched those devices since the summer.)  Can I keep the playlists from from the first PC?
    Thanks in advance for any and all help.

    Sorted it out. If anyone has this problem i reccommend visiting http://forums.ilounge.com/ipod-classic-ipod-5g-video/237546-ipod-classic-80gb-fr eezes-itunes-need-restore-plz-help-2.html#post1403546 there's some pretty good advice on it. have to go into control panel and re-format iPod into NTFS file. good luck.

  • How can I move or delete files with PL-SQL???

    I have Oracle 9i and Sun Solaris 5.8
    I have a table (“TABLE_FILENAME”) with the files name in one directory. (I read the files name in a directory and put it in a table). I charge some files with external tables and then I have to move some fields to another directory and delete others files.
    How can I delete files with PL-SQL and How can I move files with PL-SQL?
    I have the names of files and the actions (Delete o Move) in a table (“TABLE_FILENAME”) (The files in this table are dynamics).

    If you're using 9i then you will find that the new functions UTL_FILE.FCOPY and UTL_FILE.FREMOVE will allow you to do what you want. Check out the documentation for more details.
    Cheers, APC

  • How can i connect the mac with internet key?

    how can i connect the mac with internet key?
    I try but it tolds me that I haven't the javaruntime...

    I try, but to run javapreferences computer told me that I must have a Java runtime... thankyou

  • Why iCloud only allows store documents created by Pages, Numbers or Key Note ? How can I "iCloud" documents created with Word Mac or Excel mac??

    Why iCloud only allows store documents created by Pages, Numbers or Key Note ? How can I "iCloud" documents created with Word Mac or Excel mac??

    Oscar66 wrote:
    Why iCloud only allows store documents created by Pages, Numbers or Key Note ? How can I "iCloud" documents created with Word Mac or Excel mac??
    iwork for ios accepts for upload and also happily opens all your Microsoft office files, from Office97 standard doc/xls/ppt to the 2011 versions of docx,xlsx,pptx and various other of these format extensions.
    Notice : the upload feature in www.icloud.com is only active if you in fact own these apps on your iPhone/Pad/pod. it is not a feature of iWork for the Mac ( iwork09 ) which itself is not icloud capable at all.

  • With Upgrade to iOS 8.1 iPhoto has  suspended.The fotos have been transferier to Fotos, Butter the sequence  has has been corrupted. How can I move fotos in Fotos?

    Using IPad 4 I got Troubles on introduction of iOS 8.1: the app iPhoto has been suspended. The pictures have been translated to app Fotos, but the sequence got lost. Fotos does not offer a facility to move pictures. How can I move pictures in App Fotos?

    jeffr747 wrote:
    So it would seem easy for someone (lets just say a girlfriend for example) to plug my iPhone into her computer while I am staying the night and backup to iTunes.  I have my settings to "require a passcode immediately", however there was one day there was access to my passcode at her place while I was not there. So my question is three-fold:
    - How can I find out if my iphone has synced with another computer/iTunes (possible history in the iPhone)?
    - Are there additional privacy settings to make sure no one can backup my iPhone by plugging it into their iTunes?
    - If it has been backed up to another computer is there anything that can be done.
    One reason I ask this is because earlier this year her phone was backed up to my iTunes on accident.  I did not know it was there until months later, but was able to access it with software.
    Thanks!
    iPhone 5s
    iOS 8.1.2
    iTunes 12.0.1.26
    - How can I find out if my iphone has synced with another computer/iTunes (possible history in the iPhone)?
    You don't.  Nothing gets stored on the iPhone about what computers the device has been backed up to.
    - Are there additional privacy settings to make sure no one can backup my iPhone by plugging it into their iTunes?
    Yes, it's called a passcode lock.
    - If it has been backed up to another computer is there anything that can be done.
    No.  You might consider changing your Apple ID password to be on the safe side, though, as well as your security questions.

  • How can I associate 2 appleids with one account or use a different Appleid for imessage as described in another post?

    How can I associate 2 appleids with one account or use a different Appleid for imessage as described in another post?
    I have rejoined the iPhone community, not with one iPhone but with two. My wife agreed to move from the unenlightened!
    I have set up both under my apple account and want to keep it that way. But I do not want iMessages going to both phones. I would like separate message queues but share all apps and other purches from the store.
    I have created a separate AppleID for her but under Settings>Message>Receive At (it currently says 2 addresses) > ... will not allow me to change the current eMail address and when I add hers (her appleid) it errors out. The only thing I can do in the Apple ID field is to manage my account and not change it to hers.
    How can I have 2 iPhones (and my iPad) on the same account but have separate identies?
    Thanks,
    LpGrumpy

    1. Yes. Restart with the Option key held down as needed.
    2. No, it won't be a problem.
    (83373)

  • HT4059 How can I move a book from one device to another

    How can I move an iBook from one device to another

    Now when I drag and drop the photo no red # shows up and the photo stays in project 1 and also shows up in project 2 apparently creating a duplicate.
    The projects are the basic containers.  Each image and all its versions are in exactly one project.
    You can use an image in many albums, without duplicating it, also in many products like books, screensaver, slideshows.  But the projects are the basic structure of the library and you cannot have the same image in two different project, without duplicating it by storing the same original image files twice. Use albums to organize your library thematically.
    Sorry, I misread your question.   Dragging an image file between projects should move the image and all its versions to the other project.  Aperture should only duplicate the image, if you hold down the alt/options key while dragging and move the image otherwise.
    Which Aperture version are you using? And which MacOS X version?  Is your profile signature "MacBook Pro with Retina display, Mac OS 9.2.x, Aperture 3.5.1" still valid?
    In Aperture 3.6 on MacOS X 10.10.1 dragging between projects is still working as expected:

  • How can I move a photo from one project to another

    How can I move a photo from one project to another without creating a duplicate so I have the same photo in two projects.
    I seems to me in the past when I moved the photo from project 1 to project 2, I would get a number showing the # of photos being moved and you could drag and drop in the 2nd folder and the photos would disappear from project 1 and show up in project 2. is there a setting I am missing.  Now when I drag and drop the photo no red # shows up and the photo stays in project 1 and also shows up in project 2 apparently creating a duplicate.
    Any suggestion?

    Now when I drag and drop the photo no red # shows up and the photo stays in project 1 and also shows up in project 2 apparently creating a duplicate.
    The projects are the basic containers.  Each image and all its versions are in exactly one project.
    You can use an image in many albums, without duplicating it, also in many products like books, screensaver, slideshows.  But the projects are the basic structure of the library and you cannot have the same image in two different project, without duplicating it by storing the same original image files twice. Use albums to organize your library thematically.
    Sorry, I misread your question.   Dragging an image file between projects should move the image and all its versions to the other project.  Aperture should only duplicate the image, if you hold down the alt/options key while dragging and move the image otherwise.
    Which Aperture version are you using? And which MacOS X version?  Is your profile signature "MacBook Pro with Retina display, Mac OS 9.2.x, Aperture 3.5.1" still valid?
    In Aperture 3.6 on MacOS X 10.10.1 dragging between projects is still working as expected:

  • My Iphone was sync with Itunes on a computer then this computer broke down and i purchased another one. I was able to extract all the data from the old one. now how can i sync my phone with the new tunes without loosing any data?

    My Iphone was sync with Itunes on a computer then this computer broke down and i purchased another one. I was able to extract all the data from the old one. now how can i sync my phone with the new tunes without loosing any data?

    Yes, windows to Mac too.
    iTunes: How to move [or copy] your music [library] to a new computer [or another drive] - http://support.apple.com/kb/HT4527
    Quick answer if you use iTunes' default preferences settings:  Copy the entire iTunes folder (and in doing so all its subfolders and files) intact to the other drive.  Open iTunes and immediately hold down the Option (alt) key (shift on Windows), then guide it to the new location of the library.
    Windows users see tip at: https://discussions.apple.com/message/18879381

Maybe you are looking for

  • Creative MediaSource Organiser cuts the sound off with latest driv

    I have an Audigy 2 ZS with the latest drivers and the latest Creative MediaSource Organiser. What happens for no reason is that playing some music, wav or mp3 the sound goes off. This does not happen with all songs. This affects everything, no sound

  • Mail crashes every time I try to paste into a message or if I try to attach

    Mail crashes every time I try to paste into a message or if I try to attach. I upgraded to the latest security update yesterday, not sure if could be the cause. Please help!! Log of last Date/Time: 2008-03-27 16:47:01.205 -0400 OS Version: 10.4.11 (B

  • No images in Safari 4.0.3

    Hello, I seem to be the only person having this problem in the entire internet... After upgrading Safari to 4.0.3 it no longer displays images. Everything else is fine, sites load OK, flash is there, but there is no images. The only input manager I h

  • Opening Word 97 Dociments in Appleworks

    I have Word 97 documents stored as attachments to emails. When I download an attachment to my new iMac5, an icon for that document appear on my desktop. Double clicking on the icon results in the words "The Microsoft Office 2004 Test Drive has expire

  • Why are the songs in the 69 cent list not 69 cents?  Most are at their normal price right now?!

    I tried to purchase some $0.69 songs, and when I went to buy them, a message appears that says the price is now $1.29.  Why does the discounted price show when it is being billed at the original price?