Page 3 of 3 FirstFirst 123
Results 31 to 36 of 36

Thread: clickable regions of images

  1. #31
    ok, next question, when you use the new viewport control type, how do you make the clickable part move with the canvas (when you scroll up or down, the clickable region would go up or down too).

    the 2.6 release notes say this:
    In addition, the Control Object Agent class now exports two new data members called xoffset
    and yoffset. These data members are currently a constant zero (0) for all types except for
    the viewport control. The values in these data members contain the current X (left) and Y
    (top) offsets of the control's viewport. These values can be used to accurately calculate
    things such as the virtual location of mouse events on the canvass.

    reqmousedown: mouse_x, mouse_y, ctrl
    {
    x = mouse_x - ctrl.x + ctrl.xoffset;
    y = mouse_y - ctrl.y + ctrl.yoffset;
    ...
    }
    but i notice that the reqmousedown function no longer has md passed to it and i can't seem to adapt the code to my purpose. did mouse_x and mouse_y replace md.x and md.y?

    anyone with experience, a hand would be welcome

  2. #32
    alright. dunno what that documentation is getting at, but i was able to access the canvas offset using 'md'
    Code:
    reqmousedown: md
    {
        if(md.ctl)
        {
            x = md.x - md.ctl.x + md.ctl.xoffset;
            y = md.y - md.ctl.y + md.ctl.yoffset;
            //then i did the hitbox stuff based on x and y values relative to the canvas's 0 0
        }
    }

  3. #33
    erm, what's md.ctl do? *confused*
    Go TEAM VAD!! \/

  4. #34
    returns whether mousedown action happens in the viewport (when you use ctlviewport instead of ctlinfo) i think.

    i was just using md, but when i scrolled down the hit area wasn't scrolling with it.

  5. #35
    Quote Originally Posted by jeremyhardin
    alright. dunno what that documentation is getting at, but i was able to access the canvas offset using 'md'
    i can access the canvas offset by directly using the control OA.

    Code:
    cvp_palette = ctlviewport(VPW,VPH,"vp_redraw","vp_size");
    ...
    
    reqmousetrack: md
    {
    	
    	tx = md.x - LISTW - LISTMARGIN + cvp_palette.xoffset;
    }
    the cvp_palette is global.


    md is the "OA" (dunno if that's the proper term) of the reqmouse functions. it's in the experimental lscript feature docs.
    "The hardness of God is kinder than the softness of men, and His compulsion is our liberation." - C.S. Lewis


  6. #36
    i tried the control object agents and wasn't able to get it to work. but the code i wrote above worked fine and my clickable region moves with the canvas scrolling.

Page 3 of 3 FirstFirst 123

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •