I also tried overlapping canvas with the text box but that just made the
canvas in front of the text box. So I tried using append but running the
following code gives me error saying argument #2 to append should be an iup
handle which it is so I don't know why it is not working.
--IupDialog Example in IupLua
--Creates a simple dialog.
require( "iuplua" )
cv = iup.canvas {size="300x100", xmin=0, xmax=99, posx=0, dx=10}
tb = iup.text{size = "400x100", expand="YES", value="I ignore the 'g'
key!", border="YES"}
cbox = iup.cbox{
cv
}
print(tb)
iup.Append{cbox,tb}
vbox = iup.scrollbox{cbox}
dlg = iup.dialog{vbox; title="Dialog", size="100x100"}
dlg:show()
function cv:motion_cb(x, y, r)
print(x, y, r)
end
if (iup.MainLoopLevel()==0) then
iup.MainLoop()
end
Thanks,
Milind
On Thu, Aug 21, 2014 at 10:19 PM, Milind Gupta <[email protected]>
wrote:
> Hi Antonio,
> I think I did not understand the methodology you described in
> the previous email. I tried the following program:
>
> --IupDialog Example in IupLua
> --Creates a simple dialog.
>
> require( "iuplua" )
>
> cv = iup.canvas {size="300x5", xmin=0, xmax=99, posx=0, dx=10}
> vbox = iup.scrollbox{
> iup.cbox{
> iup.vbox{
> cv,
> iup.text{size = "300x100", expand="YES",
> value="I ignore the 'g' key!", border="YES"}
> }
> }
> }
> dlg = iup.dialog{vbox; title="Dialog", size="100x100"}
> dlg:show()
>
> function cv:motion_cb(x, y, r)
> print(x, y, r)
> end
>
> if (iup.MainLoopLevel()==0) then
> iup.MainLoop()
> end
>
> The canvas motion_cb is only called when the mouse moves over the canvas.
> I cannot mouse motion when it is over the text?
>
> Thanks,
> Milind
>
>
> On Tue, Aug 19, 2014 at 6:53 AM, Antonio Scuri <[email protected]>
> wrote:
>
>> Hi,
>>
>> What I suggest does not need to use CD to draw on the canvas. The idea
>> is to use the canvas just to handle mouse messages, and use BGCOLOR to set
>> a background color for the handler.
>>
>> Something like this:
>>
>> IupCbox(
>> IupVbox(
>> IupCanvas(NULL),
>> IupText(NULL),
>> NULL),
>> NULL);
>>
>> If the cbox is not occupying the whole dialog then you can place it
>> inside a IupFrame or a IupBackgroundBox, so you can set the background to
>> white.
>>
>> Then set BGCOLOR of the IupCanvas to something different then white to
>> use it as a handler, to move the vbox around the cbox.
>>
>> You must set CX and CY on the vbox so it will be positioned inside the
>> cbox.
>>
>> Then implement the button_cb and motion_cb callbacks of the canvas, and
>> use the drag delta of the canvas to change cx and cy. Take a look at the
>> source code of the IupSbox or the IupSplit that both use this same approach
>> to implement a moving handler.
>>
>> Best,
>> Scuri
>>
>>
>>
>>
>>
>> On Sat, Aug 16, 2014 at 12:51 PM, Karagy <[email protected]> wrote:
>>
>>> I ran this example using iuplua5.1.exe version 3.11.
>>>
>>> 8/16/2014 18:16, Milind Gupta пишет:
>>> > Hi Karagy,
>>> > Thanks for looking at it. I tried running the file you send
>>> but I
>>> > get the following error:
>>> >
>>> > lua: cd_buttons.wlua:112: attempt to call field 'backgroundbox' (a nil
>>> > value)
>>> > stack traceback:
>>> > cd_buttons.wlua:112: in main chunk
>>> > [C]: ?
>>> >
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> _______________________________________________
>>> Iup-users mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/iup-users
>>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>>
>> _______________________________________________
>> Iup-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/iup-users
>>
>>
>
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds. Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Iup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/iup-users