TTMSFMXNativeUICollectionView Stepper

Another piece of advice please.

I am using a stepper to increment a quantity label.

In the OnItemStepperValueChanged event I am doing the following:

lbl:=TTMSFMXNativeUICollectionViewTemplateLabel(ShoppingList.GetItemTemplateControl(ASection,ARow,4));
lbl.Text:=IntToStr(Prod.Quantity);

But  this isn't being displayed. If I do a ReloadItem it is fine but I would like to avoid doing this as I want to be able to keep my finger on the stepper so that it repeats but it crashes if I do so.

Thanks,

Ken

For performance reasons, we couldn't implement a direct update of the label, So ReloadItem will update the text, however as you are experiencing the stepper itself is also recreated / updated and looses the functionality of continuous value changing. You can overcome this by directly updating the text value of the underlying native control UILabel:


lbl:=TTMSFMXNativeUICollectionViewTemplateLabel(ShoppingList.GetItemTemplateControl(ASection,ARow,4));
lbl.Text:=IntToStr(Prod.Quantity);
lbl.Lbl.setText(NSStrEx(lbl.Text));

Kind Regards, 
Pieter
Pieter Scheldeman2014-12-03 10:13:35

Pieter,

Fantastic. Just what I wanted, thanks.

Ken

Pieter,

I now want to replace the stepper with my own UIButtons and images but I can't find a way of setting the button to repeat click. I have tried btn.Button.setMultipleTouchEnabled(True) at the point it is created but that crashes.

Any help greatly appreciated.

Ken

Did you check if btn.Button is assigned? and did you apply this in the OnApplyItemValue?


Kind Regards, 
Pieter

Thanks Pieter. I have tried doing it in the OnApplyItemValue event , it doesn't crash but it has no effect.

Ken

That's because the UIButton instance that is created only assigns an event to the UIControlEventTouchUpInside:

b.addTarget(FTemplateButtonEventHandler.GetObjectID, sel_getUid('click:'), UIControlEventTouchUpInside);

You could create your own event handler and assign it to the UIControlEventTouchDown, start a timer that performs your action and disable the timer in the default click event. 

Without additional code in your application, this is currently not possible in the collection view.

Kind Regards, 
Pieter