Yeah, I ended up going with the button that is just text approach. It seemed
to make the most sense.
I hadn't thought about subclassing UILabel, though. I don't know why, given
that I subclass the various view controllers all the time. I guess it's just
a reflection of my generally weak Object-Oriented Fu. I took the classes,
but I don't tend to think object-oriented enough (most of my work experience
has been procedural scripting, and you were right in your other reply about
that).
Anyway, I'm glad you mentioned subclassing UILabel, because I think that
will help me pull off something else I was thinking about trying.
--Chris
rnendel11 wrote
>
> Why not just create a uibutton (by default they are "custom") that is just
> text?
>
> Otherwise, you really need to subclass UILabel and override the touches
> the expose an event... something akin to
>
> public class MyTouchableLabel : UILabel
> {
> public MyTouchableLabel(RectangleF rect) : base(rect)
> {
> blah blah
> }
>
> public event EventHandler OnTouched;
>
> private void RaiseOnTouched()
> {
> }
>
> private void TouchesBegan()
> {
> // detect touched here and "raise" the event
> }
> }
>
> *** note *** I've seen/had many issues with handling large-scale
> operations in touch-events that lead to custom-event handling (such as
> above) - far better luck simply utilizing what's available in unique ways
> - for example, use a UIButton and just latch onto the "TouchUpInside"
> event - by default, when you create a UIButton via the standard
> constructor it is borderless and pretty much blank - you can set the title
> and other characteristics and simply leverage the events already generated
> by the class vs. trying to execute lots of stuff within a custom event
> associated with "TouchesBegan". However, if you really just want a label
> that is clickable, it's subclass and override time.
>
--
View this message in context:
http://monotouch.2284126.n4.nabble.com/How-to-use-a-UILabel-as-a-button-tp4655352p4655594.html
Sent from the MonoTouch mailing list archive at Nabble.com.
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch