Note that there are some explanatory texts on larger screens.

plurals
  1. POTitanium button.backgroundGradient focus
    primarykey
    data
    text
    <p>I am working on a Titanium mobile app and I have a problem with buttonfocusing while using backgroundRadient .</p> <p>I meet success using the touchstart event (changeBackgroundGradient is simple enough to avoid display here):</p> <pre><code>authButton.addEventListener('touchstart', function(e) { changeBackgroundGradient(authButton); }); </code></pre> <p>But the touchend event is not what I want. It fires only if the user end the touch <strong>on the element</strong> (behaves as a click event). Touchmove is not what I want either, as it fires as soon as the user moves.</p> <pre><code>authButton.addEventListener('touchmove', function(e) { revertBackgroundGradient(authButton); }); </code></pre> <p>What I want is: as long as the user is touching the button, the button is on focus. Something like 'ontap' and 'onrelease'. I know there are backgroundFocusedColor and backgroundFocusedImage, but no backgroundFocusedGradient.</p> <p><strong>How can I handle button focus while using backgroundGradient property?</strong> I want to have the default behaviour but it seems to stop as soon as I use the backgroundGradient property.</p> <p>Thanks.</p> <p>--edit:</p> <p>Here is the full code :</p> <pre><code> // Authenticate Button var authButton = Ti.UI.createButton({ width : '50%', height : '60', top : '15', bottom : '15', title : L('LoginView_authButton'), font: { fontSize: 20, fontFamily: 'TrebuchetMS-Bold' }, color : '#FFFFFF', textAlign : 'center', borderColor : '#3D86A9', borderWidth : '2', borderRadius : '5', backgroundGradient : { type : 'linear', startPoint : { x : '0%', y : '0%' }, endPoint : { x : '0%', y : '100%' }, colors : [{ color : '#a2d6eb', offset : 0.0 }, { color : '#67afcf', offset : 0.5 }, { color : '#3591bc', offset : 0.5 }, { color : '#1e83b1', offset : 1.0 }, ] } }); authButton.addEventListener('touchstart', function(e) { changeBackgroundGradient(authButton); }); authButton.addEventListener('touchend', function(e) { revertBackgroundGradient(authButton); }); function changeBackgroundGradient(AuthButton) { AuthButton.backgroundGradient = { type : 'linear', startPoint : { x : '0%', y : '0%' }, endPoint : { x : '0%', y : '100%' }, colors : [{ color : '#f5bd8b', offset : 0.0 }, { color : '#e59a57', offset : 0.5 }, { color : '#da7a23', offset : 0.5 }, { color : '#c35211', offset : 1.0 }, ] }; } function revertBackgroundGradient(AuthButton) { AuthButton.backgroundGradient = { type : 'linear', startPoint : { x : '0%', y : '0%' }, endPoint : { x : '0%', y : '100%' }, colors : [{ color : '#9FD3E9', offset : 0.0 }, { color : '#63AAC9', offset : 0.5 }, { color : '#348BB8', offset : 0.5 }, { color : '#2081B2', offset : 1.0 }, ] }; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload