Friday, May 7, 2010

[android-developers] Re: Why isn’t multi-touch working for imagebuttons?

What about using a TouchDelegate to examine the touches first, and
forward them as separate events?

I haven't tried it, or even thought about it for more than two
minutes, but...

On May 4, 10:42 am, niko20 <nikolatesl...@yahoo.com> wrote:
> Hi,
>
> No, it's because the android team decided to implement MultiTouch in a
> way that it only can be used on one "View". For example, ImageButtons
> are views. Each ImageButton is a seperate "View" object. The Android
> multitouch does not just map touches to multiple views like that
> (which I think it should, but the android team does not). Instead you
> end up having to create a View yourself, and drawing the three buttons
> yourself, since multitouch comes to a View as additional touch
> coordinates. In other words, you can only use multitouch "per view".
> It can't spread across multiple views. You basically need to create
> one big view object that takes up most of the screen and then draw the
> buttons yourself, and then handle the multitouch messages passed to
> that view.
>
> Unless there is an easier way that I know of, but I dont think there
> is. IMO how they "implemented" multitouch is too hackish, and should
> have been transparent to developers by the system automatically
> posting messages to each view that was being touched, instead, you
> have to rewrite the apps completely to handle it.
>
> -niko
>
> On May 2, 11:28 am, Codeman <codyrotw...@gmail.com> wrote:
>
>
>
>
>
> > I'm using imagebuttons that play sounds using SoundPool. Here is
> > example code a couple of the imagebuttons:
>
> > ImageButton Button1 = (ImageButton)findViewById(R.id.sound1);
> > Button1.setOnTouchListener(new OnTouchListener() {
>
> >         public boolean onTouch(View v, MotionEvent event) {
> >             if (event.getAction() == MotionEvent.ACTION_DOWN ) {
> >                 mSoundManager.playSound(1);
> >                 return false;
> >             }
>
> >             return false;
> >         }
> >     });
>
> > ImageButton Button2 = (ImageButton)findViewById(R.id.sound2);
> > Button2.setOnTouchListener(new OnTouchListener() {
>
> >         public boolean onTouch(View v, MotionEvent event) {
> >             if (event.getAction() == MotionEvent.ACTION_DOWN ) {
> >                 mSoundManager.playSound(2);
> >                 return false;
> >             }
>
> >             return false;
> >         }
> >     });
>
> > For some reason, it doesn't allow you to click multiple buttons at the
> > same time. Is it because I'm building for 1.6 SDK?
>
> > Thanks!
>
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to android-developers@googlegroups.com
> > To unsubscribe from this group, send email to
> > android-developers+unsubscribe@googlegroups.com
> > For more options, visit this group athttp://groups.google.com/group/android-developers?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscribe@googlegroups.com
> For more options, visit this group athttp://groups.google.com/group/android-developers?hl=en

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment