September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
11
Task/Mouse-position/Kotlin/mouse-position.kotlin
Normal file
11
Task/Mouse-position/Kotlin/mouse-position.kotlin
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
// version 1.1.2
|
||||
|
||||
import java.awt.MouseInfo
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
(1..5).forEach {
|
||||
Thread.sleep(1000)
|
||||
val p = MouseInfo.getPointerInfo().location // gets screen coordinates
|
||||
println("${it}: x = ${"%-4d".format(p.x)} y = ${"%-4d".format(p.y)}")
|
||||
}
|
||||
}
|
||||
66
Task/Mouse-position/Phix/mouse-position.phix
Normal file
66
Task/Mouse-position/Phix/mouse-position.phix
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
--
|
||||
-- demo\rosetta\Mouse_position.exw
|
||||
--
|
||||
include pGUI.e
|
||||
|
||||
Ihandle global_lbl, canvas_lbl, timer_lbl
|
||||
|
||||
function globalmotion_cb(integer x, integer y, atom /*pStatus*/)
|
||||
IupSetStrAttribute(global_lbl,"TITLE","globalmotion_cb %d, %d",{x,y})
|
||||
return IUP_DEFAULT
|
||||
end function
|
||||
|
||||
function canvas_motion_cb(Ihandle /*canvas*/, integer x, integer y, atom pStatus)
|
||||
IupSetStrAttribute(canvas_lbl,"TITLE","canvasmotion_cb %d, %d",{x,y})
|
||||
return IUP_DEFAULT;
|
||||
end function
|
||||
|
||||
function OnTimer(Ihandle /*ih*/)
|
||||
integer {x,y} = IupGetIntInt(NULL,"CURSORPOS")
|
||||
IupSetStrAttribute(timer_lbl,"TITLE","timer %d, %d",{x,y})
|
||||
return IUP_IGNORE
|
||||
end function
|
||||
|
||||
function esc_close(Ihandle /*ih*/, atom c)
|
||||
return iff(c=K_ESC?IUP_CLOSE:IUP_CONTINUE)
|
||||
end function
|
||||
|
||||
procedure main()
|
||||
Ihandle separator1, separator2,
|
||||
canvas, frame_1, frame_2,
|
||||
dialog
|
||||
|
||||
IupOpen()
|
||||
|
||||
global_lbl = IupLabel("Move the mouse anywhere on the window","EXPAND=HORIZONTAL")
|
||||
separator1 = IupLabel(NULL,"SEPARATOR=HORIZONTAL")
|
||||
canvas_lbl = IupLabel("Move the mouse anywhere on the canvas","EXPAND=HORIZONTAL")
|
||||
separator2 = IupLabel(NULL,"SEPARATOR=HORIZONTAL")
|
||||
timer_lbl = IupLabel("This one runs on a three second timer","EXPAND=HORIZONTAL")
|
||||
|
||||
frame_1 = IupFrame(IupVbox({global_lbl,
|
||||
separator1,
|
||||
canvas_lbl,
|
||||
separator2,
|
||||
timer_lbl}),
|
||||
"TITLE=IupLabel, SIZE=200x")
|
||||
|
||||
canvas = IupCanvas("MOTION_CB", Icallback("canvas_motion_cb"),
|
||||
"EXPAND=HORIZONTAL, RASTERSIZE=200x200")
|
||||
frame_2 = IupFrame(canvas, "TITLE=IupCanvas")
|
||||
|
||||
dialog = IupDialog(IupHbox({frame_1,frame_2}, "MARGIN=5x5, GAP=5"))
|
||||
IupSetAttribute(dialog,"TITLE","Mouse motion");
|
||||
IupSetCallback(dialog, "K_ANY", Icallback("esc_close"));
|
||||
|
||||
IupSetGlobal("INPUTCALLBACKS", "Yes");
|
||||
IupSetGlobalFunction("GLOBALMOTION_CB", Icallback("globalmotion_cb"));
|
||||
|
||||
Ihandle hTimer = IupTimer(Icallback("OnTimer"), 3000)
|
||||
|
||||
IupShow(dialog)
|
||||
|
||||
IupMainLoop()
|
||||
IupClose()
|
||||
end procedure
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue