Insert a textfield or checkbox on mouse click at current mouse position or drag and drop it
By : thecolonysolutions
Date : March 29 2020, 07:55 AM
it should still fix some issue Sorry for replying late, was testing actually ;) Try SOMETHING(modify the logic according to your needs) like this: code :
$('body').click(function(e){ $('body').append($('<input />').css({position:'absolute',left:e.pageX,top:e.pageY}).focus());})
|
How to draw rectangle on video using mouse left button click event and mouse drag event in Qt Creator 2.8.1 Based on Qt
By : Tim Van De Ven
Date : March 29 2020, 07:55 AM
|
Click mouse and draw fixed rectangle at mouse position in Video (python_opencv)
By : Priscilla Ellis
Date : March 29 2020, 07:55 AM
hop of those help? The problem is that you fixed a point of the rectangle and the other point follows the mouse. In your code it would be here: code :
cv2.rectangle(frame,(200,cy),(cx,128),(0,0,255),0)
cv2.rectangle(frame,(cx,cy),(cx + 80, cy +80),(0,0,255),0)
import numpy as np
import cv2
drawing = False
point = (0,0)
def mouse_drawing(event, x, y, flags, params):
global point, drawing
if event == cv2.EVENT_LBUTTONDOWN:
drawing = True
point= (x, y)
cap = cv2.VideoCapture(0)
cv2.namedWindow("Frame")
cv2.setMouseCallback("Frame", mouse_drawing)
while True:
_, frame = cap.read()
if drawing :
cv2.rectangle(frame,point,(point[0]+80, point[1]+80),(0,0,255),0)
cv2.imshow("Frame", frame)
key = cv2.waitKey(25)
if key== 13:
print('done')
elif key == 27:
break
cap.release()
cv2.destroyAllWindows()
def mouse_drawing(event, x, y, flags, params):
global point, drawing
if event == cv2.EVENT_LBUTTONDOWN:
drawing = True
point = (x, y)
elif event == cv2.EVENT_MOUSEMOVE:
if drawing is True:
point = (x, y)
elif event == cv2.EVENT_LBUTTONUP:
drawing = False
point = (x, y)
|
How do I select a sprite on a first mouse click then create a new one in the position of a second mouse click
By : shivaramrulz
Date : March 29 2020, 07:55 AM
With these it helps You don't need to wait for a second click. You need to be able to understand if, when clicking, the program should select the sprite or create a new one. A way to do this is to create a variable selected_sprite. If this variable is equal to None, that means that the click must select a sprite. It this variable holds a sprite, you can create a copy of it (or just a new sprite) at the new position. code :
addBarrierButton = Barrier()
addBarrierButton.rect.x=800
addBarrierButton.rect.y=400
all_sprites_list = pygame.sprite.group()
all_sprites_list.add(addBarrierButton)
all_sprites_list.draw(gameDisplay)
selected_sprite = None
#Main loop
while True:
for event in pygame.event.get():
if event.type = pygame.MOUSEBUTTONDOWN:
if selected_sprite is None:
for spr in all_sprites_list:
if spr.rect.collidepoint(event.pos):
selected_sprite = spr
break
else:
new_sprite = Barrier()
new_sprite.image = selected_sprite.image
new_sprite.rect.x = event.pos[0]
new_sprite.rect.y = event.pos[1]
all_sprites_list.add(new_sprite)
selected_sprite = None
|
How can I add mouse click event to Web TextBox in c#
By : user3819899
Date : March 29 2020, 07:55 AM
To fix the issue you can do How can I add mouse click event to Web TextBox in c# , If you are looking for server side click event. Try this.
|