Adobe AIR mouse wheel - air

We have an AIR application that has been around for a while that uses mouse wheel, when I built it with the latest FB it's really not responding well. As a result, I built a new project that tests only the mouse wheel - it barely intermittently responds. Mouse wheel is detected maybe once a second. The delta seems to really jump.
package
{
import flash.display.Sprite;
import flash.events.MouseEvent;
public class MouseWheel extends Sprite
{
public function MouseWheel()
{
stage.addEventListener(MouseEvent.MOUSE_WHEEL, handler);
}
public function handler(event:MouseEvent):void{
trace("Mouse Wheel" + event.delta);
}
}
}
Output:
Mouse Wheel-1
Mouse Wheel1
Mouse Wheel-1
Mouse Wheel0
Mouse Wheel-6
Mouse Wheel5
Mouse Wheel-8
Mouse Wheel4
Mouse Wheel-8
In addition, is this mouse wheel fix regarded as "the fix" or is there a better solution?
https://github.com/digi604/As3-Mouse-Wheel-Fixer

The problem is in the Mac OS settings. Recently a trackpad was purchased, and under "More Gestures" the selection "Swipe Between Pages" was enabled. For some reason, this setting enabled disrupts the Mouse Wheel for AS3, but does not affect it for any other application.
By deselecting this option, the Mouse Wheel works as expected.

Related

Checkable Tool Button Icon Color Changes

I want to have effect like VLC Play Pause Button. Based on other posts, I have
Have created resource file with play pause icons(transparent background).
Have created checkable toolbutton through qt designer.
Have assigned icon for normal off/on through qt designer.
However, when I run the application and click button(IsCkecked is true), the icon turns slightly grey. I do not want background color to change. I am not sure, what is causing this behaviour as well.
Does anyone know reason behind this?
Thanks in advance.
Set stylesheet to the play button.
Like this...
QPushButton
{
background-color:#fffff;
}
QPushButton:pressed
{
background-color:#fffff;
}
Set stylesheet to the play button.
Like this.....
QPushButton
{
background-color:#fffff;(this color can be changed as you want)
}
QPushButton:pressed
{
background-color:#fffff;( same as above )
}

how to see mouseReleased() event outside canvas using processing.js

I have an object I want to drag around the screen with the mouse in Processing. I set acquired to true on mouse down over the object, and to false on mouse up, thus:
void mousePressed() {
if (overThing()) {
acquired = true;
}
}
void mouseReleased() {
acquired = false;
}
I then query acquired in my update(), and drag the object if it is true.
void update() {
\\ other stuff...
if (acquired) {
\\ drag thing code ...
}
}
This all works fine in Processing. mouseReleased() gets called whether I release the mouse inside or outside the active window.
However, when I move the code to Chrome, using processing.js (v1.4.8), mouseReleased() is not called if I release the mouse outside the canvas (whether the mouse is still over the web page, or outside the browser window). So when I return the (now unclicked) mouse to the canvas, the object is still getting dragged around.
I tried including a test of mousePressed in update(), but that also returns true in these circumstances.
Any help on what I need to do to make mouse state changes outside the canvas visible with processing.js?
I don't know about Processing specifically, but releasing mouse buttons outside a widget is a common issue in GUI development.
I suspect that you have no way of knowing the precise time when the mouse is released outside the widget, but you do have two options:
Set acquired = false in mouseOut(), as #Kevin suggests.
I assume there is some type of mouseEntered() method in Processing, and also some way of knowing if the mouse button is currently pressed (either a global variable, or an event object passed to mouseEntered()). You can catch the mouse entered event, check if the mouse has been released, and set acquired = false then.
Like so:
void mouseEntered() {
if (mouse button is pressed) {
acquired = false;
}
}
Edit: From your comments, #Susan, it seems like there is a bug in processing.js, where mousePressed is not set to false if the mouse button is released outside the canvas. One thing pointing to this being a bug is that the mouse movement example on the processing website also shows this behaviour.
Depending upon how much control you have over the website this is going on, and how much effort you want to go to, you could fix the bug yourself by writing some javascript (separate from your processing code):
Define a mouseUp() event on the page <body>, to catch all mouse release events on the page.
In the mouseUp() event, check if the event comes from your Processing control. (There is probably an event object passed to the mouseUp() function, and you might have to give your Processing control an ID to identify it)
If the event doesn't come from your Processing control, then fire a mouseUp event yourself, on the Processing control. This should (hopefully!) trigger a mouse event inside your Processing code.
I'm not sure what Processing will make of the mouse (x,y) position being outside its control when it handles the event you send it. You might want to set a flag on the event object (assuming you can add extra data to the event object) to say "don't use the (x,y) position of this event - it's outside the control".
Edit2: It was easier than I thought! Here is the JavaScript code to detect the mouse being released outside of the Processing canvas and send the mouseReleased event to the canvas. I've tested it on the mouse movement example from the Processing website, and it fixes the bug.
It uses jQuery (although it could be re-written to not use jQuery), and it assumes your Processing canvas has the ID "processingCanvas":
$(':not(processingCanvas)').mouseup(function(){
Processing.getInstanceById('processingCanvas').mouseReleased();
});
To use this code, include it anywhere in your page (in a JavaScript file or in <script> tags) and make sure you have the jQuery library included before this code.
The Processing object allows JavaScript to call any functions defined in your Processing code. Here I've used it to call Processing's built in mouseReleased() function, but if you wanted to call a custom function to handle the mouse-released-outside state differently, then you could.
You should use the mouseOut() function to detect when the mouse leaves the sketch:
void mouseOut() {
acquired = false;
}
More info in the reference here.

When testing smartmenus in Selenium, submenus do not get exposed on hover over

Standard Selenium mouseover / hover mechanism does not work
Actions builder = new Actions(driver);
builder.click(actionsButton).moveToElement(addNewLink).build().perform();
However, click action unexpectedly works:
Actions builder = new Actions(driver);
builder.click(actionsButton).click(addNewLink).build().perform();
Which is the exact opposite of what happens when a user navigates the menus - they get exposed on hover over and closed on click.
The culprit turns out to be Smartmenus. It has a non-standard code that uses absence of a mouse to detect mobile devices. When a mobile device is detected, Smartmenus stops recognizing hover over and instead begins responding to click/tap.
Whatever Selenium does to simulate the mouse movement does not convince Smartmenus that the real mouse is present.
Switching to click instead of hover over also does not work reliably in cases where a user moves the mouse on the computer running Selenium tests.
I've settled for a workaround that tries to click and, if unsuccessful, switches to hover over:
Actions builder = new Actions(driver);
builder.click(actionsButton).click(addNewLink).build().perform();
try {
wait.until(ExpectedConditions.visibilityOf(pcLink));
}
catch (TimeoutException e) {
builder.click(actionsButton).moveToElement(addNewLink).build().perform();
wait.until(ExpectedConditions.visibilityOf(pcLink));
}
pcLink.click();

Custom QLineEdit, focusProxy and QDataWidgetMapper

This problem is driving me nuts so I would appreciate some assistance. Obviously done the usual googling and checking qt docs but have not found any solution.
We need to customize a standard QLineEdit. Here is a prototype:
class MyLineEdit : public QLineEdit
{
Q_OBJECT
public:
MyLineEdit(QWidget* a_parent)
{
QTextEdit* textEdit = new QTextEdit(this);
textEdit->setMinimumWidth(width() / 2);
textEdit->setMaximumWidth(width() / 2);
textEdit->setMinimumHeight(30);
textEdit->setTabChangesFocus(true);
// background color red
QPalette p = textEdit->palette();
p.setColor(QPalette::Base, QColor(244,20,20));
textEdit->setPalette(p);
textEdit->setVisible(true);
setFocusProxy(textEdit);
}
};
This shows a QLineEdit with a QTextEdit on-top of it.
Using the keyboard to change focus works as expected (the TextEdit gets the focus and not the LineEdit).
Using the mouse to change focus works as expected (selecting the LineEdit forwards the focus to the TextEdit).
The MyLineEdit and regular QLineEdit instances are added to a QDataWidgetMapper. We obviously use setModel method call on the QDataWidgetMapper instance.
In the QDialog, changing focus from a QLineEdit using keyboard or mouse triggers an invocation of our implementation of QAbstractItemModel::setData.
In the same QDialog, changing focus from a MyLineEdit using keyboard or mouse does NOT trigger an invocation of our implementation of QAbstractItemModel::setData.
This problem seems to be related to the setFocusProxy API. When removing setFocusProxy line;
changing focus from a MyLineEdit (specifically the QLineEdit) using keyboard or mouse does trigger an invocation of our implementation of QAbstractItemModel::setData.
changing focus from a MyLineEdit (specifically the QTextEdit) does NOT trigger an invocation of our implementation of QAbstractItemModel::setData.
How can I use setFocusProxy and get invocation of QAbstractItemModel::setData?
What am I doing wrong?

Custom context menu XAML for WP8

I try to implement a custom ContextMenu in a LongListSelector.
I'm not using the ContextMenu from Microsoft.Phone.Controls.Toolkit, it's basically the same as in the Rowi App:
(source: hiddenpineapple.com)
Approach 1
My list item toggles a VisualState on hold and an overlay is shown with controls in it.
The problem
I can't find a way to go back to the default state when the user clicks outside of the list item (as in the default ContextMenu).
Approach 2
I've implemented a custom template for the toolkit ContextMenu which looks exactly the same. I had to move its margin top to -itemHeight, as by default it is below the item.
The problem
The problem with this solution is, that it automatically closes itself when opening and I couldn't figure out how to avoid this.
Another problem was that it didn't work well with TiltEffect.IsTiltEnabled from the Toolkit (visual problems).
I need your help
Any suggestions on how to get this working?
Answer
Thanks to Cheese, now I know how to properly close the menu when the user clicks outside.
His suggestion was to get the coordinates of a Tap event on the current page, and check if it's inside the menu. When not, close the menu.
So I added a Tap listener to the page when the menu opens, and removed it when the menu closes. From the page listener I got the event coordinates and could check if it's inside the control which holds the menu (same size and position). I received the position of the control with Point leftUpperPoint = control.TransformToVisual(page).Transform(new Point(0, 0)) and the rightLowerPoint by adding the ActualWidth and ActualHeight.
But then I realized:
Why should I even calculate if the tap is inside the menu? I always want to close the menu when the user taps anywhere on the screen. If it's outside, yes. If it's on a menu button, yes.
Another modification I made was to listen for MouseLeftButtonDown instead of Tap as it also triggers when the user swipes.
So I removed this code and came up with the following:
private void ToggleMenu(object sender, System.Windows.Input.GestureEventArgs e)
{
PhoneApplicationFrame frame = ((PhoneApplicationFrame)Application.Current.RootVisual);
VisualState state = this.States.CurrentState;
if (state == null || state.Name == "DefaultState")
{
frame.MouseLeftButtonDown += MouseDownDelegate;
this.State = "MenuState";
}
else
{
frame.MouseLeftButtonDown -= MouseDownDelegate;
this.State = "DefaultState";
}
}
private void MouseDownDelegate(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
ToggleMenu(sender, null);
}
This works perfectly!
Thanks to Cheese for the hint.
Something like this by #denniscode http://dotnet.dzone.com/articles/rowi-show-tap-menu
Approach 1 problem
The best solution would be:
Get the menus coordinates, when user makes a tap - you check are tap coordinates on menu or not, if not - dissmiss - simple.
Approach 2 problem
I guess you had some button in a corner and when you tapped on it - nothing happened? And when you dissmissed the Tilt all worked. It seems that tilt works faster than a click, so, tilt changes the button coordinates, and device thiks you have missed/or dragged off
You can use what #ScottIsAFool suggested and maybe create another Dependency Property on your TapMenu control of type UIElement named CloseWhenTappedElement and automatically listen for Tap events inside your control once set. For example
<Grid x:Name="TapArea"/>
<TapMenu CloseWhenTappedElement="{Binding ElementName=TapArea"}/>