windows.sendkeys equivalent in flex/adobe air - apache-flex

Is it possible to capture user typed inputs from keyboard and overwrite user entered text with pre-defined words in Flex/Adobe Air? I'm looking for a functionality in Adobe Air something like "typinator" does.

Yes, you can do this.
You can set up a KeyListener event on the stage, and it should catch any and all keystrokes. After that, you can send whatever command you like to whatever component you like. If you are looking to access programs outside of AIR, like windows.sendkeys can do, please look at this post for how that might work.
Specific components can stopPropagation(), but I don't think text input objects do this by default. See this doc for more on capture/bubble.

Related

On-screen buttons to emulate keyboard characters? (web)

I'm making a game similar to the proper franchise "Agar," and on mobile I'd like the players to be able to split and eject mass. For this, I was wondering whether I could make on-screen buttons which emulate the keys "W" for example. Thus, clicking it will eject mass.
I did some searching and I discovered something called "accesskey" in HTML, but this requires the user to also click on ALT (or whatever their browser supports) to trigger it. Is there something similar to this which does not require ALT, and just needs the key (e.g. "w") to shoot? I'd just like it to click W for you, not execute a function upong clicking W.
Just use JQuery, in your javascript code, put something like:
$(document).keypress(function(e) {
if(e.which == 87) {
ejectMass();
}
});

Flex Application for PlayBook Text Input Variable

I know this is probably a very simple question, but can someone please walk me through how to take what a user inputs into a s:TextInput and use that as a variable in a JSON data request?
Basically, I want to have a user enter a search term, like "math" and then have that placed into a variable so I can use it in a JSON request.
Something like public var q:String, except that my search box (and hence user input) is on another "view" of the application.
I've just started with Flex Mobile applications and I might be way out of my league. Does anyone know how to do this?
The containing view should still be able to access teh child view's properties (and therefore controls); you just need the control(s) to have a unique ID, which then becomes a property name. That said, I would consider the whole search feature to be self-contained, so it'd have its own controller (action script class for handling actions) wired up to the search button, adn have a reference to the view that it can extract the info from, etc.

take a snapshop of a qgraphicsview

I am using Qt 4.5 and a qgraphicsscene/view to show video to the user.
I would like to provide a "take a snapshop" button and I am sure that there is a pretty straightforward way much simpler of everything I am thinking about.
How can I do this elegantly?
BTW, the code is here :
http://gitorious.org/handy
You can use the method QWidget::grab(). This method renders the given widget to a pixmap and returns that pixmap. Then you can do whatever you like with that, like saving to a file using QPixmap::save().
See QScreen::grabWindow() and QWidget::grab().
With grabWindow you can even capture a window outside of your application, e.g. the screenshot example program:
http://doc.qt.io/qt-5/qtwidgets-desktop-screenshot-example.html

How to change the state in Adobe Flex, using ActionScript?

I`m really new to Flex and ActionScript so please be patient with me.
I want to implement this script: tinyurl.com/yafqrqb
...that is doing this "magic" : tinyurl.com/y9qg32r
...but I want to tweak it a little on InfoWindowTabbedComponent. To be more precisely I`m trying to insert links in that tabs, and when you click one the state will change.
You can see my custom InfoWindowTabbedComponent at the end of the post As you can see, right now I have 2 functions that open url`s.
What I`m trying to do is to change this:
var adobeURL:URLRequest = new URLRequest("http://www.microsoft.com" );
navigateToURL(adobeURL, "_self");
Into something that change the current state.
Can you please help me?
Here`s my custom InfoWindowTabbedComponent: http://pastebin.com/f387bc3b9
I'm not sure I understand what you want to do. If you just want to set the selected Tab, instead of calling navigateToURL() set myTabNavigator.selectedIndex (or selectedChild)
If you really want to change the state, each component has a currentState property, but then you would have to define the states first (via the tag)
And if you really want to navigateToURL() you could navigate to javascript:somefunction() and then set the application state via ExternalInterface, but that would be horribly circumstantial.
Cheers,
Jörg

Flex component access other component

I have 2 components for example (editor.mxml using mx:windows), when I click an edit button, I want to get the current value from the other component's datafield? (datagrid.mxml using mx:window)
I do know how to access the main MXML's datagrid by parentDocument or Application.application method, but stumped block if I want to access other way as mentioned above. Keep the code as simple as possible.
You could either do dependency injection, that is, give component A a reference to component B so that they can communicate directly (example of tighter coupling,) or have both components communicate through a common mediator using events (example of more loose coupling.)
Both of those options would be implemented wherever it is that you're creating those components (A and B in this example) and adding them to the display list.
This might be more complicated than it deserves, and it smacks of Pattern-Fever, but you could use a mediator class that listens for the CLICK event from the button and knows enough about the other component to query its property. It could even transmit that data using a custom event, which the button listens for.
While this involves three classes instead of two, it often turns out to be easier to have two components that focus on looking good and one that worries about coordination.
Cheers
Try this:
FlexGlobals.topLevelApplication
This points Your root. From the root You can grab every element You want.
You can also add an id to the custom component like this,
<custom:Editor id="myCustomComponent">
</Editor:AddressForm>
and
access your datagrid's value like this,
var data:ArrayCollection = myCustomComponent.DatagridID.dataProvider;

Resources