On 07/06/2017 at 13:57, xxxxxxxx wrote:
I don't success to get it to work properly. The main issue is I don't know when to start drag event. Same for end it. So for exemple it didn't make the difference beetween a simple click and a drag event.
Moreover kills event doesn't seem to work.
Here is an exemple
import c4d
class Area(c4d.gui.GeUserArea) :
xValue = 0
yValue = 0
def DrawMsg(self, x1, y1, x2, y2, msg) :
self.DrawSetPen(c4d.Vector(.2))
self.DrawRectangle(x1, y1, x2, y2)
def drag_message(self, msg, result) :
bc_click = c4d.BaseContainer()
self.GetInputState(c4d.BFM_INPUT_MOUSE, c4d.BFM_INPUT_MOUSELEFT, bc_click)
mousex = bc_click.GetLong(c4d.BFM_INPUT_X)
mousey = bc_click.GetLong(c4d.BFM_INPUT_X)
self.MouseDragStart(c4d.KEY_MLEFT, mousex, mousey, c4d.MOUSEDRAGFLAGS_DONTHIDEMOUSE | c4d.MOUSEDRAGFLAGS_NOMOVE)
mx = mousex
my = mousey
drag_result, dx, dy, channels = self.MouseDrag()
first = True
drag = False
while drag_result == c4d.MOUSEDRAGRESULT_CONTINUE:
drag = True
if first:
print 'Start'
first = False
mx += dx
my += dy
if dx==0.0 and dy==0.0:
drag_result, dx, dy, channels = self.MouseDrag()
continue
self.KillEvents() #Don't work
drag_result, dx, dy, channel = self.MouseDrag()
print "Mouse Dragging at position [%f,%f]" % (mx, my)
if self.MouseDragEnd() == c4d.MOUSEDRAGRESULT_FINISHED and drag:
print "Mouse Dragging Ended: ", self.MouseDragEnd()
return
def Message(self, msg, result) :
self.drag_message(msg, result)
if msg.GetId() == c4d.BFM_INPUT:
print 'clicked'
return c4d.gui.GeUserArea.Message(self, msg, result)
class MyDialog(c4d.gui.GeDialog) :
def __init__(self, area) :
self.area = area
def CreateLayout(self) :
self.SetTitle("My UserArea")
self.AddUserArea(1000, c4d.BFH_SCALEFIT|c4d.BFV_SCALEFIT)
self.AttachUserArea(self.area, 1000)
self.GroupEnd()
return True
def main() :
area = Area()
dialog = None
dialog = MyDialog(area)
dialog.Open(dlgtype=c4d.DLG_TYPE_MODAL_RESIZEABLE, defaultw=500, defaulth=500)
if __name__=='__main__':
main()
As you could see if you click its also print you drag. Hope you understand my problem ^^'. Who is Get the start of a drag event and get the end of a drag event. Like that in the Message function I can do if START_OF_DRAG : self.drag_message, and if END_OF_DRAG : print 'end'