Hi,
what is the syntax of the Clickable Event for a Canvas Object?
Tried below _Clicked and _ObjectClicked (found in abmcanvas.4.25.min.js) but there is no logentry when clicked. The mouse pointer changes to a hand, so clickable is recognized for the object.
The objects, valve, are created in the sub BuildValve. See below.
The objects are defined as global to handle the events:
Adding the two canvas objects canvasValveIn and canvasValveOut to the canvas in ConnectPage().
Canvas Object building a Valve
what is the syntax of the Clickable Event for a Canvas Object?
Tried below _Clicked and _ObjectClicked (found in abmcanvas.4.25.min.js) but there is no logentry when clicked. The mouse pointer changes to a hand, so clickable is recognized for the object.
The objects, valve, are created in the sub BuildValve. See below.
B4X:
Sub canvasValveIn_Clicked(objectId As String)
Log("canvasValveIn clicked:" & objectId)
End Sub
Sub canvasValveIn_ObjectClicked(objectId As String)
Log("canvasValveIn object clicked:" & objectId)
End Sub
The objects are defined as global to handle the events:
B4X:
Dim canvasValveIn As ABMCanvasObject
Dim canvasValveOut As ABMCanvasObject
Adding the two canvas objects canvasValveIn and canvasValveOut to the canvas in ConnectPage().
B4X:
Dim canvasTankFarm As ABMCanvas
canvasTankFarm.Initialize(page, "canvasTankFarm", ABM.COLOR_TRANSPARENT, ABM.INTENSITY_NORMAL, 400,400, False)
canvasValveIn = BuildValve("canvasValveIn",50,10,10)
canvasValveOut = BuildValve("canvasValveOut",50,50,10)
canvasTankFarm.AddObject(canvasValveIn)
canvasTankFarm.AddObject(canvasValveOut)
page.Cell(1,1).AddComponent(canvasTankFarm)
Canvas Object building a Valve
B4X:
Sub BuildValve(id As String, valvex As Int, valvey As Int, valvewidth As Int) As ABMCanvasObject
Dim valve As ABMCanvasObject
Dim linestrokecolor As String = ABM.COLOR_RED '"#888888"
valve.InitializeAsRectangle(page, id, valvex,valvey,valvewidth,valvewidth,True)
valvex = 0
valvey = 0
valve.beginPath
valve.lineWidth(1)
valve.lineCap(ABM.CANVAS_LINECAP_SQUARE)
valve.strokeStyleColor(linestrokecolor)
'TopLeft to BottomRight
valve.moveTo(valvex,valvey)
valve.lineTo(valvex+valvewidth,valvey+valvewidth)
'BottomRight to TopRight
valve.moveTo(valvex+valvewidth,valvey+valvewidth)
valve.lineTo(valvex+valvewidth,valvey)
'TopRight to BottomLeft
valve.moveTo(valvex+valvewidth,valvey)
valve.lineTo(valvex,valvey+valvewidth)
'BottomLeft to TopLeft
valve.moveTo(valvex, valvey+valvewidth)
valve.lineTo(valvex,valvey)
' MiddleMiddle to TopMiddle
valve.moveTo(valvex+(valvewidth/2), valvey+(valvewidth/2))
valve.lineTo(valvex+(valvewidth/2),valvey)
valve.strokeStyleColor(linestrokecolor)
valve.Clickable = True
valve.stroke
Return valve
End Sub
Last edited: