Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Mon Feb 22, 2021 12:48 pm Post subject: SET_TOOLTIP_TEXT@ + CHAR(10) |
|
|
In this example there is a %pl[full_mouse_input] region with a callback which updates the %th[at_cursor,ms_style] for the region with the current x,y coordinates at the mouse. At first glance this appears to work, but the call to SET_TOOLTIP_TEXT@ does not recognise the presence of CHAR(10), so the text in the tooltips which should be over two lines, is displayed as a single line.
Code: | module demo_mod
use clrwin
implicit none
integer, parameter :: dp=kind(1.d0), n = 10
real(dp) :: x(1:n), y(1:n)
integer :: show_coord = 1
integer(7) pl_handle
character(len=256) :: coord_string = ''
contains
integer function gui()
integer iw, i
forall (i=1:n) x(i) = dble(i-1) ; forall (i=1:n) y(i) = x(i)*x(i)
iw = winio@('%mn[Exit]&','exit')
iw = winio@('%th[at_cursor,ms_style,delay]&', 1, 0)
iw = winio@('%`rb[Show coordinates]&', show_coord)
call winop@('%pl[full_mouse_input,x_array,title=Quadratic,gridlines,frame,colour=blue,width=2,symbol=10,smoothing=4]')
iw = winio@('%nl%^?pl@&', 400, 400, n, x, y, pl_cb, coord_string)
iw = winio@('%lc&',pl_handle)
iw = winio@(' ')
gui = 1
end function gui
integer function pl_cb()
integer(7) gx,gy
integer i
real(kind=dp) px, py
character(len=10) str_x, str_y
if ( clearwin_string@('callback_reason') .eq. 'MOUSE_MOVE') then
if (show_coord .eq. 1) then
gx = CLEARWIN_INFO@('GRAPHICS_MOUSE_X') ; gy = CLEARWIN_INFO@('GRAPHICS_MOUSE_Y')
i = GET_PLOT_DATA@(gx,gy,px,py)
if ( px .gt. minval(x) .and. px .lt. maxval(x) .and. py .gt. minval(y) .and. py .lt. maxval(y) ) then
write(str_x,'(SPF10.3)') px ; write(str_y,'(SPF10.3)') py
coord_string = trim(adjustl(str_x))//char(10)//trim(adjustl(str_y))
print*, coord_string
call SET_TOOLTIP_TEXT@(pl_handle,coord_string) ! ## Why does SET_TOOLTIP_TEXT@ fail to detect the char(10) in cood_string?
! call SET_TOOLTIP_TEXT@(pl_handle,trim(adjustl(str_x))//char(10)//trim(adjustl(str_y))) ! ## Same output as above line
else
call SET_TOOLTIP_TEXT@(pl_handle,'')
end if
else
call SET_TOOLTIP_TEXT@(pl_handle,'')
end if
end if
pl_cb = 2
end function pl_cb
end module demo_mod
program main
use demo_mod
implicit none
integer i
i = gui()
end program main |
|
|