Topic: Mouse event
Hi Jeff
A procedure to move a cross on screen (to draw a cross on the screen) causes a problem.
It's a short procedure as follows:
Starting with registering the mouse next is call loop the rest is done by the handle_click call back routines. There also stop idle is called so that clearmouseclick is executed. See below
What happens:
After return to the current window menu every mouse click else where on the graphic screen results in a segmentation fault! Of course these mouse clicks without any target makes no sense but could happen.
Only after closing that current window and restarting it again this fault does not happen again.
I made a small test program with only the routine move cross and the same happened!
I understood that clearmouseclick clears the events. But my impression is that the mouse event is still (a bit) active until the current graphic window is closed too. The Windows controlled mouse is working but also a mouse click outside the Window menu gives the wrong response resulting in a crash.
What can I do to solve this problem? Do I have to run the mouse handling in a separate thread?
Regards, Klaus
SUBROUTINE MOVE_CROSS (x_cross, y_cross, finish) ! exit when finished
USE AppGraphics
Use W_ords_to_pixels
Logical finish
DOUBLE PRECISION x_cross, y_cross
finish=.false.
! __________________________________________________________________
Call registermousehandler (MOUSE_LB_DOWN, handle_click)
Call registermousehandler (MOUSE_RB_DOWN, handle_clickrb)
Call loop ! the corresponding world ordinates related to mouse x and y are defined in handleclick
call clearmouseclick(MOUSE_LB_DOWN)
call clearmouseclick(MOUSE_RB_DOWN)
contains
subroutine handle_click(x, y)
integer::x, y
logical Clicked
print *,'move cross: handle click started for LB_down'
Clicked = ismouseclick (MOUSE_LB_DOWN)
If(clicked)then ! x+y > 0)then
call line (x-20,y,x+20,y)
Call line (x,y-20,x,y+20)
x_cross = dble(real(x -x_offset))/scale_x ; y_cross = ywtot- dble(real(y+y_offset))/scale_y
Print*,'move cross: handle click got ordinates by LB_down',x,y
Call stopidle ( )
end if
end subroutine handle_click
subroutine handle_clickrb(x,y)
integer::x, y
logical Clicked
print *,'move cross stops: handle click for RB_down',x,y
Clicked = ismouseclick (MOUSE_RB_DOWN)
If(clicked)then
Finish = .true.
Call stopidle ( );return
Print*,'handle click move cross finished'
end if
end subroutine handle_clickrb
End SUBROUTINE MOVE_CROSS