For my current UI, I need to have LongPress on labels. I usually subclass and with a small timer, get that working in a jiffy. I checked, all controls in XCode have at least pointerUp and PointerDown. I frankly don’t understand why Xojo elected to neuter its label.
Is it possible to implement that by declare ? Has anybody done that already ?
Funny how, as I am working simultaneously with the Android version of Check Writer, I see now that all controls in B4A have mouseDown, mouseUp, Click and LongPress. Gawd, if we only had such a luxury !
Michel… for whats it is worth… UILabel (the iOS Control that the Xojo label control is most likely based on), does not have an “addTarget” attribute (which is what is used to add touch gestures to a control)
Based on your post, I tried [in Swift] to add a “.touchDown” event to a UILabel and got
Makes me think that perhaps B4A is “faking” it, by either subclassing a UITextField and not using UILabel at all, or bundling the UILabel with a “container” that handles the touches… Either or both are things you should be able to do in Xojo with what little you have available to you.
It does have an addTarget:action:for: method, and you can override the begin/continue/endTracking: methods.
Without subclassing, it should be possible to attach a GestureRecognizer for the LongPress Gesture like Mcheal requested. There are several declares out there in the wild for recognizers.
Well, living in poverty is not fun. I ended up creating a replacement subclass based on Canvas…
B4A is for Android, so underneath things are very different.
B4A still has to work inside the iOS world… so unless they are making their own controls, it all comes back to UIKit
Heck… what you did, may be very well what B4A is REALLY doing
The more I go, the more cautious I become about adding code libraries. I had to remove Beardsley’s gesture recognizer because it conflicted with my existing complement of classes. I cannot remove dtPlugins since I absolutely need printing, and I also need Jason’s ImprovedIosApplication to have the WillResignActive to save data when the app quits being front.
Yet again, it is quite a pity that Xojo never seemed to take into account feature requests around iOS. We have to use quite a number of dark recipes, and some of them have bad side effects.
[quote=299151:@Dave S]B4A still has to work inside the iOS world… so unless they are making their own controls, it all comes back to UIKit
Heck… what you did, may be very well what B4A is REALLY doing[/quote]
Dave, B4A is a PC development tool to produce Android apps. It has absolutely nothing to do with the iOS world.
LOL… yup… of course you’re right… and the foundation controls and their attributes for the Android OS, may or may not be in line with how Apple decided to design corresponding iOS controls…
Sorry, I accidentally looked up UIControl, but UILabel is no subclass of it.
Instead of the action methods, UILabel inherits from UIView which inherits from UIResponder. You can subclass it all the touches
withEvent: methods. Basically, yes, a Canvas will do, and yes: Mixing different libraries is challenging at least.
Indeed. Jean-Paul Devulder just sent me a project that successfully adds touch to a label He’s got talent.
But I bet he used “gestures” not “addTarget”…