forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

callback mouse click
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
Bartl



Joined: 16 Oct 2009
Posts: 58
Location: München

PostPosted: Fri Jun 19, 2015 9:04 am    Post subject: callback mouse click Reply with quote

Who can help me:
Is there a callback to check, if a left_mouse_click was done without using the format codes (%gr) or (%dw) analogous the ('%ac) codes in the example (see ??? in attached example).
If not what solutions exists to realise this?

Code:

winapp
program mouse_click_test
include <windows.ins>
external ienter,iesc
!external ileft_mouse_click  ????????
character*5 data1, data2
integer*4 ifocus,ncontrol,icontrol(2)
common/focus_control/ifocus,ncontrol,icontrol

data1 = '11111'
data2 = '22222'
i=ifw()
call add_focus_monitor@(ifw)
ncontrol = 2
i=winio@('%ac[Enter]&',ienter)
i=winio@('%ac[ESC]&',iesc)
!i=winio@('%?????????????&',ileft_mouse_click)   ?????????????
i=winio@('%nl%rs%lc&',data1,icontrol(1))
i=winio@('%nl%rs%lc',data2,icontrol(2))
call remove_focus_monitor@(ifw)       
end

integer*4 function ienter()
include <windows.ins>
integer*4 ifocus,ncontrol,icontrol(2)
common/focus_control/ifocus,ncontrol,icontrol
ienter=1
write(*,*)"ienter pressed"
! do something
if(ifocus.eq.icontrol(1))call set_highlighted@(icontrol(2))
if(ifocus.eq.icontrol(2))call set_highlighted@(icontrol(1))
end

integer*4 function iesc()
include <windows.ins>
integer*4 ifocus,ncontrol,icontrol(2)
common/focus_control/ifocus,ncontrol,icontrol
iesc=0
write(*,*)"ESC pressed"
! End
end

integer*4 function ifw()
include <windows.ins>
common/focus_control/ifocus,ncontrol,icontrol(100)
ifw=2
ifocus=clearwin_info@('FOCUSSED_WINDOW')
end

! ????????????????????????
!integer*4 function ileft_mouse_click()
!include <windows.ins>
!integer*4 ifocus,ncontrol,icontrol(2)
!common/focus_control/ifocus,ncontrol,icontrol
!ileft_mouse_click = 1
!write(*,*)"ileft_mouse_click pressed"
! do something
!end
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Fri Jun 19, 2015 3:41 pm    Post subject: Reply with quote

CLEARWIN_STRING looks like it might help.

Eddie
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Mon Jun 22, 2015 8:35 am    Post subject: Reply with quote

The short answer is that it is not possible to attach a callback to a mouse click in the same way that you would attach a callback to a key press. You might be able to use %mg with WM_LBUTTONDOWN but this could be tricky. I can supply further details if you want to try this approach.
Back to top
View user's profile Send private message AIM Address
Bartl



Joined: 16 Oct 2009
Posts: 58
Location: München

PostPosted: Mon Jun 22, 2015 9:37 am    Post subject: Reply with quote

Paul,
i am very interested to find o solution and would be happy about a sample.
Thank you.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Mon Jun 22, 2015 12:08 pm    Post subject: Reply with quote

Here is something to get you started but it only works when you click on the main window. It may not work when you click on a control within the main window.

Code:
WINAPP
program main
use mswin
integer iw,n
integer,external::cb
n = 100
iw=winio@("%mg&", WM_LBUTTONDOWN, cb)
iw=winio@("%`rd", n)
end

integer function cb()
integer iw
integer,external::winio@
iw = winio@("OK")
cb = 3
end
Back to top
View user's profile Send private message AIM Address
Bartl



Joined: 16 Oct 2009
Posts: 58
Location: München

PostPosted: Mon Jun 22, 2015 2:49 pm    Post subject: Reply with quote

Paul,
thank you, this works super but the problem is really that it doesn't work within a control.
Is their a possibility to attach a separate callback to a mouse click within a control(perhaps with CLEARWIN_STRING) ?
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Mon Jun 22, 2015 2:54 pm    Post subject: Reply with quote

Which control do you have in mind?
Back to top
View user's profile Send private message AIM Address
Bartl



Joined: 16 Oct 2009
Posts: 58
Location: München

PostPosted: Mon Jun 22, 2015 3:04 pm    Post subject: Reply with quote

mostly the rs control like for example
i=winio@('%nl%rs%lc &',cpos,icontrol(1))
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Mon Jun 22, 2015 4:24 pm    Post subject: Reply with quote

%rs uses a Microsoft Edit control. When you click on it, it gets the focus.

Perhaps you need to monitor the focus using add_focus_monitor@.
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Mon Jun 22, 2015 8:20 pm    Post subject: Reply with quote

It looked to me that you could only detect a mouse click inside a control, and as Paul's solution works outside the controls, maybe you have to have separate code for inside and out.

In the callback from your control CLEARWIN_STRING@(CALLBACK_REASON) should allow you to detect all manner of mouse click and release events according to the documentation, which is what I meant with my original terse post.

Paul's solution of detecting gaining focus surely works for only the first click?

Eddie
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Tue Jun 23, 2015 7:25 am    Post subject: Reply with quote

I suspect that "CALLBACK_REASON" is not useful in this context.

Code:
module mymod
character(20) txt
contains
 integer function cb()
 use clrwin
 print*, trim(clearwin_string@("callback_reason")), ":", trim(txt)
 cb = 2
 end function
end module

WINAPP
program main
use mymod
integer iw
integer,external::winio@
txt = " "
iw=winio@("%^rs", txt, cb)
end
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Tue Jun 23, 2015 7:47 am    Post subject: Reply with quote

Here is a sample for add_focus_monitor@.
As Eddie says, it is only useful for the first click on a given control.
A second click on the same control has no effect.

Code:
module mymod
character(20) txt
integer han,h1,h2
contains
 integer function cb()
 use clrwin
 integer h
 h = clearwin_info@("focussed_window")
 han = 0
 if(h == h1) han = 1
 if(h == h2) han = 2
 call window_update@(han)
 cb = 2
 end function
end module

WINAPP
program main
use clrwin
use mymod
integer iw
integer,external::winio@
txt = " "
call add_focus_monitor@(cb)
iw=winio@("%ff%nl%rs%lc&", txt, h1)
iw=winio@("%ff%nl%rs%lc&", txt, h2)
iw=winio@("%ff%nl%rd", han)
end
Back to top
View user's profile Send private message AIM Address
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Tue Jun 23, 2015 3:24 pm    Post subject: Reply with quote

I have a bunch of adages, and one of them is that if what you want to do seems impossible or difficult, then quite possibly what you are attempting is a non-standard way of working in a Windows application!

For further advice/suggestions, please tell us exactly where the mouse pointer might be when you want to detect clicks, and also, why you want them and what you would do with them when (and if) you got them ...

Eddie
Back to top
View user's profile Send private message
Bartl



Joined: 16 Oct 2009
Posts: 58
Location: München

PostPosted: Tue Jun 23, 2015 7:36 pm    Post subject: Reply with quote

Paul,
your sample with add_focus_monitor@ seems to be a solution for me and I will try it.

What I want to do:
I youse my short sample code from Fri Jun 19, 2015 for input real values, integer values, characters aso.
When I press for example the ENTER button, the ienter() function will be called, the control jumps into the next line and I can do many tests within the ienter() function, like
-tests for defined characters like "yes", "no"
-convert the characters to integer values with „read (cfeld,'(i10)') izahl
-convert the characters to real values with „read (cfeld,'(f10.3)') rzahl
-test the integer or real values for predefinded values like 1,5,7,13 , values greater than or less than and, and, and
This works really very good since a long time.

The recurrent problem is, when I change from one control to the next not with the ENTER button but with a left-coursor-click the ienter() callback and it’s tests will not be called.

PS: In my original program I can change the controls with many key buttons like %ca[UP], %ca[DOWN] aso.
It's not a disaster, when there is no solution, but of course it would be helpful.
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Wed Jun 24, 2015 8:13 pm    Post subject: Reply with quote

Bartl,

I think that you are trying to do too much with %rs (I salute your imagination!), and you should use the individual types of edit box for each type of variable.

If you have unlimited time and patience, and you really do want to have a general purpose input box that responds to all types of input including various mouse clicks, then you could program it in a small %gr box and process all or most of the events in its callback.

Eddie
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group