onGestureZoom
Event fired in response to use performing a zoom gesture on a touch enabled device.
Parameters
<centerX>
horizontal position of a point at the center of the zoom gesture
<centerY>
vertical position of a point at the center of the zoom gesture
<nDelta>
amount of zoom determined by the size and speed of the user's movement.
Indicates how much the height and width should be changed compared with
the current height and width. Value is converted to units matching the current form's metric
property.
Property of
Form, Subform, all form components that have their own windows handle.
Description
OnGestureZoom() is an event that will fire when a user performs a gesture using two fingers on either a touch screen or touch pad where they first touch both fingers to the device and than move them closer together to zoom in or farther apart to zoom out.
Note that either both fingers must initially touch within the boundaries of the object or the first touch must be within the boundaries of the object.
On a device that does not support touch or on which touch support is disabled, onGestureZoom() will not fire.
Firing Sequence:
As the user performs the gesture, onGestureZoom() will fire multiple times. The first time it fires to indicate that a zoom gesture has begun. The value of nDelta should be ignored the first time onGestureZoom fires.
When onGestureZoom() fires additional times, nDelta can be used to determine how much to change the width and height of an object. When nDelta is a positive number, it indicates that the object size should be increased. When nDelta is a negative number it indicates that the object size should be decreased. When updating an object's width and height it is usually also necessary to prevent setting them too large or too small in order to prevent making the object larger than its container or so small that the object becomes too small to display properly or too small to zoom it back to a larger size.
When a zoom gesture is completed, onGestureZoom() will fire one last time with nDelta set to zero,
Example:
** END HEADER -- do not remove this line
//
// Generated on 08/01/2016
//
parameter bModal
local f
f = new TestButtonGesturesForm()
if (bModal)
f.mdi = false // ensure not MDI
f.readModal()
else
f.open()
endif
class TestButtonGesturesForm of FORM
with (this)
onOpen = class::FORM_ONOPEN
onGestureZoom = class::FORM_ONGESTUREZOOM
metric = 6 // Pixels
height = 512.0
left = 231.0
top = 8.0
width = 627.0
text = ""
endwith
this.PUSHBUTTON1 = new PUSHBUTTON(this)
with (this.PUSHBUTTON1)
onOpen = class::PUSHBUTTON1_ONOPEN
onGestureZoom = class::PUSHBUTTON1_ONGESTUREZOOM
height = 396.0
left = 126.0
top = 22.0
width = 469.0
text = "Pushbutton1"
endwith
this.CHECKBOX1 = new CHECKBOX(this)
with (this.CHECKBOX1)
height = 44.0
left = 133.0
top = 451.0
width = 161.0
text = "Checkbox1"
endwith
this.RADIOBUTTON1 = new RADIOBUTTON(this)
with (this.RADIOBUTTON1)
height = 55.0
left = 371.0
top = 440.0
width = 168.0
text = "Radiobutton1"
group = true
value = true
endwith
function PUSHBUTTON1_onGestureZoom(centerX, centerY, nDelta)
local nFinalDelta, nMaxWidthDelta, nMaxHeightDelta, nMaxDelta, nMinWidth, nMinHeight
if this.firstZoom
this.firstZoom = false
else
if nDelta = 0
// Zoom is completed
this.firstZoom = true // reset this.firstZoom
this.borderStyle := this.saveBorderStyle // reset this.borderstyle
else
// change borderstyle to indicate zoom is occurring
this.borderStyle := 6 // drop shadow
nFinalDelta = nDelta
if nDelta > 0
nMaxWidthDelta = this.parent.width - (this.left + this.width)
nMaxHeightDelta = this.parent.height - (this.top + this.height)
nMaxDelta = iif(nMaxWidthDelta > nMaxHeightDelta, nMaxHeightDelta, nMaxWidthDelta)
if nFinalDelta > nMaxDelta
nFinalDelta = nMaxDelta
endif
else // nDelta < 0
nMinWidth = 64
nMinHeight = 32
nNewWidth = this.width + nDelta
nNewHeight = this.height + nDelta
nMaxWidthDelta = nDelta
if nNewWidth < nMinWidth
nMaxWidthDelta = -(this.width - nMinWidth)
endif
nMaxHeightDelta = nDelta
if nNewHeight < nMinHeight
nMaxHeightDelta = -(this.height - nMinHeight)
endif
nMaxDelta = min(abs(nMaxWidthDelta), abs(nMaxHeightDelta))
if abs(nFinalDelta) > abs(nMaxDelta)
nFinalDelta = nMaxDelta
endif
endif
with (this)
width += nFinalDelta
height += nFinalDelta
endwith
// reset borderstyle
this.borderStyle := this.saveBorderStyle
endif
endif
return true
function PUSHBUTTON1_onOpen()
this.firstZoom = true
this.saveBorderStyle = this.borderstyle
return
function form_onGestureZoom(centerX, centerY, nDelta)
local nFinalDelta, nMaxWidthDelta, nMaxHeightDelta, nMaxDelta
if this.firstZoom
this.firstZoom = false
else
if nDelta = 0
// zoom is finished
this.firstZoom = true
else
// update form width and height
nMaxParentWidth = 1366
nMaxParentHeight = 768
nFinalDelta = nDelta
nMaxWidthDelta = nMaxParentWidth - (this.left + this.width)
nMaxHeightDelta = nMaxParentHeight - (this.top + this.height)
nMaxDelta = iif(nMaxWidthDelta > nMaxHeightDelta, nMaxHeightDelta, nMaxWidthDelta)
if nFinalDelta > nMaxDelta
nFinalDelta = nMaxDelta
endif
with (this)
width += nFinalDelta
height += nFinalDelta
endwith
endif
endif
return true
function form_onOpen()
this.firstZoom = true
return
endclass