onClick ( execute ) event of qx.ui.basic.Image? - qooxdoo

Is there any onClick (execute) of qx.ui.basic.Image ?
var myImage = new qx.ui.basic.Image("myApp/image.png");
myImage.addListener("execute", function(e) {
// some action
});
Qooxdoo prompts an error:
There is no event handler for the event 'execute' on target
Is it a must to use a qx.ui.basic.Button with Image ?

It depends on what you want. If you want all the stuff like focusable and keyboard accessable, you have to make it a button. Still, you can easily remove the look of the button in the theme or by setting the decorator to null. If you don't need all that and only want a click event, you can listen instead of execute to click which will work as expected on images as well.

Related

Set button action in controller

I have a navigation view with one button in the toolbar. Based on the view pushed, the button's label and functionality should chang. I've managed to do this by creating many buttons and activating them as needed (hide/show)
Instead of doing that approach I'd like to have just one button and in the controller change the text and action. Something along these lines:
this.getButton().setHtml("new text");
this.getButton().action = "newaction";
setHtml works, but setting the action doesn't. Examining the button in the console, I see the action changes but when I click it, it responds to the previous action.
Any suggestions on how to approach this?
Thanks
You should use setText instead of setHtml that, err... Doesn't seem to exist! And setHandler to change the handler function.
Alternatively, since you say that you're working in a controller, you can attach a function to the click event of the button and, inside this listener function, decide what action to execute in the current context.

How to cancel event of spinner field in ExtJS 4.1?

I am developing application using ExtJS 4.1. I have one spinner field and I want to change value of that method programatically. I have set up listeners like change, spinup and spindown for this same spinner field.
Now I would like to know how to prevent listener method of these events getting fired only when I change the value of spinner field through my program?
For example,
var mySpinner = Ext.ComponentQuery.query('#foopanel > #mySpinner')[0];
mySpinner.setValue(2000);
When mySpinner.setValue(2000); line is executed, change event of mySpinner gets fired and as I have listener method for this change event, that listener method is executed.
Is it possible to prevent invocation of change event listener method?
Thanks..
You could suspend all events by calling
mySpinner.suspendEvents();
mySpinner.setValue(2000);
mySpinner.resumeEvents();
That would be the cleanest an easiest way IMO
And that's also a usecase why this methods exist

Popup Never Closes

WPF is really getting me out of my nerves here. I configured a popup with some complex content (grid, buttons etc..). I set its StaysOpen property to False and IsOpen to True on a textbox MouseDown preview event.
Ths thing is that it opens but never closes when clicking anywhere outside the window.
Any suggestions?
Thanks!
UPDATE:
My popup has buttons inside. When I click one of those, the popup closes when I click outside of it. Is some weird stuff happening to the events routing?
Looks like the popup won't close if opened by any other control event. I just binded the IsOpen property to the IsChecked property of a ToggleButton to simulate a combobox.
Thanks for all your answers.
I was also having this issue, except on the PreviewMouseButtonUp event of a Button. The assumption that there is some bug with Popups and trying to open them in Tunneling events was accurate and led me down the path to my fix (which is a little more generic).
I needed to resolve this (the host control was generic / could be several types of controls) by listening for the bubbling event instead of the tunneling event, specifically with the AddHandler(RoutedEvent,Delegate,Boolean) method in order to capture handled events.
WAG the issue lies somewhere when transitioning from tunneling to bubbling.
I use code behind to initialize popup, and I've found that it's not closed if ran sync from other UI action like mouse event. To workaround this I run it async:
public static void ShowPopupMessage(string message)
{
DispatcherHelper.UIDispatcher.BeginInvoke(new Action(() =>
{
var popup = new Popup
{
Child = new AutoHideMessage(message),
StaysOpen = false,
IsOpen = true
};
}));
}
I set IsOpen on a textbox MouseDown preview event.
Set it to what? And where is the TextBox hosted?
I can only guess with the scant information provided, but I'd say when you click outside the Popup, your event handler is firing and opening it up again.
You can use LostFocus event of the PopUp. If the focus is not within the popup, set its IsOpen to false to close it.

ToolStripSplitButton behavior override

I'm trying to understand what do I have to do to override the behavior of the ToolStripDropDown control on System.Windows.Forms where if you use this constructor:
var button = new ToolStripSplitButton("text","path to image", clickEventHandler)
then the drop down will only show if I keep the mouse pressed and if I use this other
var button = new ToolStripSplitButton("text","path to image")
then the drop down will show when I click.
It is clear to me that supplying a click event handler is very explicit in saying "hey, when I click, execute this" but in the case of a ToolStripSplitButton the distinction blurs a bit because of the split nature of the control itself.
So, what I like to do is
a) When the user clicks on the button part of the ToolStripSplitButton, the click event handler executes as normal
b) When I click OR press the mouse on the arrow part of the ToolStripSplitButton then the drop down shows
Is there any OOB property/method to do just this?
Thanks
The ToolStripSplitButton has two click handlers. One is called "Click" and the other is called "ButtonClick". The one from the constructor is the "Click" handler and fires no matter where on the control you click. The "ButtonClick" handler only fires when you click the button itself, not the arrow.
Try this:
var button = new ToolStripSplitButton("text","path to image");
button.ButtonClick += clickEventHandler;

ExtJS: focus field

I have a window containing a form (formPanel). Users can show this window clicking on a button in an ExtJS environment. I would like that when the user clicks the button to show the window, a specific field inside the form contained by the window will focus (by this I mean that the cursor should move to that field so that the user can insert data without needing to click on the field itself first).
I tried some solutions, but could not get them work. Any hints?
Here is what I tried, using some examples I found... but it does not work as expected. This function() is called by the ExtJS button in my interface:
function openCardForm(IDUser){
//Reset the value of this field which may be still there from the prev. usage
Ext.getCmp('assignFormCARDNUMBER').reset();
formAssignCard.getForm().load({
url: 'gen/jsonUser.php',
params:{IDUser:IDUser},
waitMsg: 'Loading...'
});
//Try to focus the Card field when rendering the form
Ext.getCmp('assignFormCARDNUMBER').on("render",function(){
Ext.getCmp('assignFormCARDNUMBER').focus(true,10);
});
win.show();
}
try on show instead.
Or Use
defaultButton : yourComponentToFocusOn
A bit confusing but the defaultButton can be any component (not necessary to be an actual button)
You can also try setting the tabindex of the field to zero in its config options...that way you wont even need to add a listener to detect the show event.
ie:
tabIndex:0

Resources