View previous topic :: View next topic |
Author |
Message |
GEWV
Joined: 25 Nov 2013 Posts: 19
|
Posted: Tue Jan 21, 2014 11:52 am Post subject: WaitAction |
|
|
In a loop, the mouse info to be queried only when an action is performed.
Code: | do while (endless)
call get_mouse_position@(x,y,flag)
call temporary_yield@()
end do |
The CPU is being used even though nothing is done.
The same result I get when I permit_another_callback views before the loop.
[img]http://tu-dresden.de/die_tu_dresden/fakultaeten/fakultaet_maschinenwesen/iet/ew/trnsys/temp_yield[/img] |
|
Back to top |
|
|
IanLambley
Joined: 17 Dec 2006 Posts: 490 Location: Sunderland
|
Posted: Tue Jan 21, 2014 1:29 pm Post subject: |
|
|
If you have a %gr window, then specify a callback function and "full_mouse_input". For each mouse movement within the graphics window a call to your specified callback function is performed and you can check the mouse info within that function.
If this is not for a graphics window, then forget I mentioned this!
Ian |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2819 Location: South Pole, Antarctica
|
Posted: Tue Jan 21, 2014 2:32 pm Post subject: |
|
|
Ian made good point for %gr. As to other uses of mouse it would be wise to curb excessive CPU use by adding to the DO loop above the CALL SLEEP1@(smalldelay) which is specifically designed for not sucking processor time ( versus SLEEP@ as I last time used it a decade ago) with smalldelay from 0.01 to a quarter a second depending on usage |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 Location: Salford, UK
|
Posted: Tue Jan 21, 2014 3:15 pm Post subject: |
|
|
Calling temporary_yield@ causes ClearWin+ to process the Windows message queue at the point that you specify. If you omit the call then normally ClearWin+ will make the call automatically at an appropriate point.
If you need the call in the current context and do not make it, then Windows may not respond (e.g. to mouse movements).
In a simple program ClearWin+ will automatically call (something like) temporary_yield@ just before the Fortran STOP (or END) statement. |
|
Back to top |
|
|
|