Jump to content

Recommended Posts

  • Moderators

Every now and then I read something so refreshing, that it jolts the old braincells out of its rut.
10/GUI describes a new gui system concept which does away with keyboards and mice, relying on gestures instead
Fun, and somehow very convincing

Recently I needed a mechanism to cycle through an image carousel. There are different ways of doing this, but for touch enabled devices I opted for a one-finger swipe gesture.

W3Image.OnSwipeLeft := procedure(sender: TObject) begin ... end;

The implementation of OnSwipeLeft below is somewhat project specific, but includes the following

- it is made a property of all customcomponents descendants (helper construct)
- it extends TNotifyEvent, so it does not only return the sending object (sender: TObject), but also the event object (event: variant). That way OnSwipeLeft has access to properties of both (and handles all event-types)
- it checks if the device has touch capabilities and uses the touch-api if that is the case, otherwise it uses pointerevents

Demo project  (covering all swipe orientations. Verbose code, can be simplified)

The touch-api supports multi-touch events to a certain maximum. My phone can handle 5 fingers.
That makes it possible to implement for instance two-finger swipes to slide-in the next form.

Form.OnFormSwipeRight := lambda Application.GotoForm('Form2', feFromRight); end;




Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...