Appcelerator Button image not changing in ios - ios

Hi i am using a UIButton and i want to change its image property on touchstart and touchend events.
Here is something i am following
$.button.addEventListener('touchstart',function(e){
e.source.image="image-pressed.png";
});
$.button.addEventListener('touchend',function(e){
e.source.image="image-normal.png";
});
But i am wondering its not going to happen images are not changing on these events though the event is properly being fired on both touch events.
Kindly guide me how i can place my normal and pressed image for a button.
Thanks.

Try this:
$.button.addEventListener('touchstart',function(e){
$.button.image = "image-pressed.png";
});
$.button.addEventListener('touchend',function(e){
$.button.image = "image-normal.png";
});
It may also happen that your event is bubbling up to any of its parent or parent of parent (if parent has such events attached to it) which means that e.source will not be the button itself. So it's always safe to use $.Button_ID to access property like image or title.

Related

Adding custom icons to konvajs transformer anchors

Please have a look at
www.jsbin.com/wigokojina/1/edit?html,css,js,output
I've added custom svg icons to the konva transformer, but the middle rotator icon is draggable even if i set draggable to false. The two other icons are fine and as expected, as far as dragging is concerned.
My questions are:
How do i disable the dragging for the rotator anchor, so that the icon doesnt move?
How do i disable all event handlers for an anchor, and add one click event? Ive tried shape.off('dragmove') etc. The only thing that helps is setting listening to false, but then im prevented from adding a new event listener. I want to disable all event handlers for the top right anchor, and add one onclick listener afterwards.
Is it possible to add the icons to the shape itself using fillPatternImage? Instead of adding the icon as a new shape like im doing. If its possible, please provide an example using the jsbin.
Thanks very much :-)
At the current moment konva#4.0.16 doesn't support fully customized Konva.Transformer. But you are making a good attempt.
How do i disable the dragging for the rotator anchor, so that the icon doesn't move at all?
You can reset the position in transform event (almost as you do it). But at the current moment, for performance reasons, inside transform events all anchors has "old" positions. So you see dragging of the icon from rotater anchor. To fix the issue we can force update a transformer:
circle.on('transform', function(){
transformer.update();
for (var button in buttons) {
var selector = button.replace('_', '-');
var shape = transformer.findOne('.' + selector);
var icon = transformer.findOne('.' + selector + '-icon');
icon.position(shape.position());
icon.x(icon.x() - 5.25); icon.y(icon.y() - 5.25);
layer.batchDraw();
}
});
How do I disable all event handlers for an anchor, and add one-click event
It can be something like this:
shape.listening(false);
icon.on('click', () => {
alert('delete');
});
Demo: https://jsbin.com/galetahara/4/edit?js,output

Simulate a click() programmatically on a Div

I'm trying to fire an event programmatically. My problem is that I have two SVG on two DIVs and I want to be able to change the border of the DIV I have clicked. To do that I thought to pass the DIV inside my classes and then trigger a click on it once I click on anything. (if there is a better way, please tell me)
I have the following code:
div = querySelector(divName);
svgElement = new svg.SvgSvgElement();
div.append(svgElement);
div.onClick.listen(_setBorders(1));
later I pass the svgElement to another class
ell.show(svgElement);
where show is
show(svg.SvgElement element) {
if (element.parent is DivElement){
_parentDiv= element.parent as DivElement;
element.children.add(_group);
}
}
_parentDiv is of course a DivElement, which I use for an internal onClick()
_onClick(MouseEvent e) {
window.console.info("onClick Ell");
_parentDiv.click();
}
I'm expecting to see the _setBorders(1); I defined with the main div, but it doesn't work. The weird thing is that when I check with the debugger set to the _parentDiv.click() I see that _parentDiv has the event correctly set.
I suppose click() doesn't work as I expected. Any Idea?
If you want that _setBorders(1) is called on click events you have to use :
div.onClick.listen((_) => _setBorders(1));

How do you use the showhide effect found in the Dart Widget Package

I am trying to use the ShowHide effect that comes with Kevin Moore's widget package here:
http://dart-lang.github.io/widget.dart/#showhide
Not sure how to use this. Anyone got an example I can look at ?
Basically all I want is for a dropdown to show with one of those effects if a certain event happens.
Your tips appreciated.
Thanks.
You need to add a listener for an event to an element in the DOM, and then use ShowHide.toggle(element, effect) to trigger an effect. Here is an example which listens for a click on a button, and toggles FadeEffect on an image each time it is pressed:
var button = query("#fadeButton")
..onClick.listen((event) {
ShowHide.toggle(query("#fadeImage"), effect: new FadeEffect());
});
If you wanted to fade in/out a dropdown when you click on a menu bar, then substitute "fadeButton" for the menu which listens for clicks, and "fadeImage" with the dropdown element.
Also, any other effect can be substituted for FadeEffect, such as DoorEffect, ScaleEffect, ShrinkEffect, etc.

DART - Resize div element event

I am using CSS3 resize: vertical; to allow the user to resize a Div, and would like to be notified when this happens (so that I can adjust the size of other elements with Dart code if necessary).
How can I attach an event listener for the user resize event?
( DivElement.on.resize does not exist.)
When you want to observe event which is not listed under the on getter, you can use $dom_addEventListener to set event listener.
Thus, if you would like to use something like the unexisting divElement.on.resize, you can use :
divElement.$dom_addEventListener("resize", (e) {
// event occurs
});
That said, unlike click event, the resize event doesn't seem to be fired (even in javascript).

AS3 Movieclip not responding to Mouse_Wheel event

I'm creating a container as a MovieClip and adding a mousewheel handler, then adding items to it like so:
container = new MovieClip();
addChild( container );
container.addEventListener( MouseEvent.MOUSE_WHEEL, HandleWheel );
container.addChild( item );
// etc. adding more items
However the mousewheel is only responding when the mouse is over one of the items, not over the visible areas of the container between the items. Is there any way to make it so the event is always triggered when the mouse is over the container, not just over its children?
I don't know if it's relevant, but the container has a mask set. I tried adding the listener to the mask and it didn't do anything, though.
If I set the opaqueBackground of the container to red, I can see the container bounds. I don't understand why the mouse wheel event isn't triggering when the mouse is within these bounds. If this is really not possible, is there another way to handle the situation without needing the container to respond directly to mouse events?
Thanks for any help.
"The opaque background region does not respond to mouse events."
From: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html#opaqueBackground
You may need to add a rectangle to the background to act like a bounding box. It can have its alpha set to 0%. The problem is that if the cursor is on a completely transparent area of the object, it will just not pass mouse events to it, as it shouldn't (otherwise we'd always be stuck with rectangular areas); in that case, adding the transparent backgrounds fixes it.

Resources