(AGK version: 108.14)
Submitted: 2013-06-30 07:38:51
Setvirtualresolution(640,480)
SetPrintSize(30)
ResetTimer()

Repeat
    if GetPointerState()=1
        print("Click or Touch Active")
    endif
    sync()
Until Timer()>20
End
(AGK version: 2.0.16)
Submitted: 2016-01-01 08:00:27
//agk 2.0.16
//MR

// Click or Drag

type TDrag
	spr
	hit
	hittime as float
	clicked
	drag
	ox as float
	oy as float
endtype

local item as TDrag
item.spr=CreateSprite(0)

SetSpritePositionByOffset(item.spr,50,50)

do
 
	if GetPointerPressed()
		if GetSpriteHitTest(item.spr,GetPointerX(),GetPointerY())
			item.hit=1
			item.hittime=timer()
			item.ox=GetSpriteXByOffset(item.spr)-GetPointerX()
			item.oy=GetSpriteYByOffset(item.spr)-GetPointerY()
		else
			item.hit=0
		endif		
	elseif GetPointerState()=1 and item.hit=1
		if timer()-item.hittime>0.5
			item.drag=1
		endif
	elseif GetPointerReleased()
		if timer()-item.hittime<=0.5
			item.clicked=1			
		endif
		item.hit=0
		item.drag=0
	endif 
	
	Info("Hit",item.hit)
	Info("Clicked",item.clicked)
	Info("Drag",item.drag)

	if item.clicked=1
		item.clicked=0
		SetSpriteColor(item.spr,Random2(32,255),Random2(32,255),Random2(32,255),255)
	endif

	if item.drag=1
		SetSpritePositionByOffset(item.spr,item.ox+GetPointerX(),item.oy+GetPointerY())
	endif

	sync()
loop
end


function Info(name$,value)

	print(name$+" : "+str(value))

endfunction


Help make AGK better by submitting an example for this command!
(All examples are subject to approval)
Login to post an example of your own.