Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8317983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:47:54+00:00 2026-06-08T21:47:54+00:00

I am working on a Titanium mobile app and I have a problem with

  • 0

I am working on a Titanium mobile app and I have a problem with buttonfocusing while using backgroundRadient .

I meet success using the touchstart event (changeBackgroundGradient is simple enough to avoid display here):

authButton.addEventListener('touchstart', function(e) {
    changeBackgroundGradient(authButton);
});

But the touchend event is not what I want. It fires only if the user end the touch on the element (behaves as a click event).
Touchmove is not what I want either, as it fires as soon as the user moves.

authButton.addEventListener('touchmove', function(e) {
    revertBackgroundGradient(authButton);
});

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.

How can I handle button focus while using backgroundGradient property?
I want to have the default behaviour but it seems to stop as soon as I use the backgroundGradient property.

Thanks.

–edit:

Here is the full 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
        },
        ]
    };
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:47:57+00:00Added an answer on June 8, 2026 at 9:47 pm

    I did the trick using touchCancel

    authButton.addEventListener('touchstart', function(e) {
        changeBackgroundGradient(authButton);
    });
    
    authButton.addEventListener('touchcancel', function(e) {
        revertBackgroundGradient(authButton);
    });
    

    I first misunderstood the documentation:

    touchcancel
    Fired when a touch event is interrupted by the device

    The touch event is indeed interrupted by the device if you end the touch outside the element. So it works as intended : as long as you press the screen, the button is orange, once you release the press outside of the button, the button goes back blue.

    Thanks for your hints Sismetic, it made me figure out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on building an iPhone app with Titanium Mobile 1.0 and I see
I am writing my app in JavaScript using Appcelerator's Titanium IDE. I've been working
I'm currently working on a cross-platform mobile app and have gone through the process
Hi I am working Android application development using titanium studio.I have developed small application.my
I am working on an iPad app using appcelarator titanium and need to iterate
I am working on an iPhone app for an event and I have to
I'm working on a Titanium app and have build a function to run sqlite
I am working on a small iPhone app using Titanium/Appcelerator. Now what I am
In Titanium mobile indexOf function of String is not working properly. console.log( test2.indexOf( /tes/i
I am working with Titanium Studio and I have to make an HTTP get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.