nativescript-checkbox icon indicating copy to clipboard operation
nativescript-checkbox copied to clipboard

Tap event getting wrong value

Open oncul opened this issue 7 years ago • 12 comments

Hello i need to add a event checkstate changed. I am trying add a tap event. But its getting first state of switch. I i tap checked switch getting checked prop True.

oncul avatar Mar 16 '17 14:03 oncul

Can you provide all of your code involved and platform, device info?

On Thu, Mar 16, 2017, 9:43 AM Cagatay Oncul [email protected] wrote:

Hello i need to add a event checkstate changed. I am trying add a tap event. But its getting first state of switch. I i tap checked switch getting checked prop True.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bradmartin/nativescript-checkbox/issues/25, or mute the thread https://github.com/notifications/unsubscribe-auth/AFulhJ0sxfhdRE4vES1CEgHHSSWwCaOLks5rmUqVgaJpZM4MfZrZ .

bradmartin avatar Mar 16 '17 14:03 bradmartin

<CheckBox:CheckBox row="1" col="2" tap="checkTap" colspan="2" text="Show" checked="{{ filter.show }}" />

exports.checkTap = function(args){
	console.log(args.object.checked); // returns first state of checkbox
}

I am trying on Android. I need to get event check state changed.

oncul avatar Mar 16 '17 14:03 oncul

I've not tested anything but try calling the toggle method on the check box to switch its value. Then get the value.

bradmartin avatar Mar 16 '17 15:03 bradmartin

If you want the change event use the following

<CheckBox:CheckBox row="1" col="2" checkedChange="checkTap" colspan="2" text="Show" checked="{{ filter.show }}" />
exports.checkTap = function(args){
	console.log(args.value); // returns first state of checkbox
}

triniwiz avatar Mar 16 '17 16:03 triniwiz

@triniwiz thank you. İ didnt see that property :)

oncul avatar Mar 16 '17 17:03 oncul

@triniwiz its not worked.

oncul avatar Mar 17 '17 08:03 oncul

#27

i added a pull request for this event handler

oncul avatar Mar 17 '17 10:03 oncul

@cagatayoncul works fine for me in Angular

triniwiz avatar Mar 18 '17 15:03 triniwiz

hi triniwiz , is it possible to change the color property of checkbox . like: our checkbox border color is grey when i click on it then checkbox color will be fill with different color. plz reply .

himanshu331 avatar Apr 13 '17 11:04 himanshu331

@himanshu331 android or iOS

triniwiz avatar Apr 14 '17 03:04 triniwiz

In nativescript ..

himanshu331 avatar Apr 14 '17 07:04 himanshu331

Try to put the code inside the setTimeout function:

//xml <CheckBox:CheckBox id="item1" text="testName" tap="_checkTapped"/>

//script function _checkTapped() { console.log("tapped"); setTimeout(() => { let checkBox = topmost().getViewById('item1'); console.log('checked prop value = ' + checkBox.checked); }, 100); }

GoodLadCarlos avatar Oct 01 '18 11:10 GoodLadCarlos