0Pricing
Jetpack Compose Academy · درس

‏pointerInput وdetectTapGestures

اكتشف النقر والنقر المزدوج والضغط المطوّل

‏pointerInput وdetectTapGestures درس مجاني في Jetpack Compose Academy على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Jetpack Compose Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Jetpack Compose Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

The Gateway to Touch

To handle raw touch in Compose you reach for the pointerInput modifier. It gives any element a place to read finger events directly. 👆

Add It to Any Composable

Attach pointerInput in a Modifier chain. Inside its lambda you get a gesture scope where you can listen for taps, drags, and more.

Box(Modifier.pointerInput(Unit) {
  // gesture detectors go here
})

Detect Simple Taps

The friendliest helper is detectTapGestures. It bundles tap, double tap, long press, and press into one tidy call for you.

detectTapGestures(onTap = { /* tapped */ })

A Single Quick Tap

The onTap lambda fires when a finger presses and lifts without moving much. It receives the Offset where the tap landed.

detectTapGestures(onTap = { offset -> println(offset) })

Catch a Double Tap

Pass onDoubleTap to react to two quick taps in a row. It is perfect for a like or zoom shortcut on an image. 💙

detectTapGestures(onDoubleTap = { /* zoom in */ })

Hold for Long Press

The onLongPress lambda fires after the finger stays down past a threshold. Use it to open context menus or selection mode.

detectTapGestures(onLongPress = { /* show menu */ })

Track the Press Itself

Use onPress to know the moment a finger touches down. Its lambda is suspendable, so you can await release or cancellation.

detectTapGestures(onPress = { awaitRelease() })

Every Tap Carries Position

Each tap callback hands you an Offset in pixels, measured from the top-left of the composable. Read it to know exactly where the user touched.

The Key Argument Matters

The first argument to pointerInput is a key. When it changes the gesture block restarts, so pass any state your handlers depend on.

Modifier.pointerInput(enabled) { /* restarts if enabled flips */ }

Gestures Run in Coroutines

The pointerInput block is a suspend scope. That is why detectors can await events frame by frame without blocking the UI thread.

Combine Several Callbacks

One detectTapGestures call can take tap, double tap, and long press together. Compose figures out which one the user meant.

detectTapGestures(onTap = {...}, onLongPress = {...})

Quick Check

Which helper bundles tap, double tap, and long press into one call?

Recap: Raw Taps Made Easy

You met pointerInput and detectTapGestures for tap, double tap, and long press. They are your foundation for custom touch handling. 🎉

الأسئلة الشائعة

هل درس «‏pointerInput وdetectTapGestures» مجاني؟

نعم — نص درس «‏pointerInput وdetectTapGestures» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Jetpack Compose Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Jetpack Compose Academy 4 دروس في المجموع.

ماذا ستتعلم في «‏pointerInput وdetectTapGestures»؟

اكتشف النقر والنقر المزدوج والضغط المطوّل تتمرن على Jetpack Compose Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Jetpack Compose Academy؟

لا تُشترط خبرة سابقة. Jetpack Compose Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.

كم من الوقت يستغرق درس «‏pointerInput وdetectTapGestures»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Jetpack Compose Academy هذا؟

نعم. كل درس في Jetpack Compose Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. ‏pointerInput وdetectTapGestures
  2. السحب والتمرير والدفع
  3. ‏Transform: التحريك والتكبير والتدوير
  4. اتصالات التمرير المتداخل
← العودة إلى Jetpack Compose Academy