Help with object resizer please

Wednesday, May 13, 2009 by homer1324 | Discussion: DesktopX Tutorials

Hi again,

 

Consider this;

I have one parent object (image) with several text objects as children of said object

I have a script attached to the parent object which is;

 

Const var = 1.3
Sub Object_OnMouseEnterEx(obj)
    For Each elem In Desktopx.Object("parent").Children

        elem.left = elem.left*var
        elem.top = elem.top*var

       
        elem.width = elem.width*var
        elem.height = elem.height*var
       
        elem.SetFont "Arial", elem.fontsize*var, elem.fontbold, elem.fontitalic, elem.fontunderline, elem.fontstrikeout, 0
        elem.left = elem.left
    Next
        Object.left = Object.left - (((object.width*(var)) - Object.width)/2)
        Object.top = Object.top - (((object.height*(var)) - Object.height)/2)
       
        Object.width = Object.width*var
        Object.height = Object.height*var
       
        Object.SetFont "Arial", Object.fontsize*var, Object.fontbold, Object.fontitalic, Object.fontunderline, Object.fontstrikeout, 0
End Sub

Sub Object_OnMouseLeaveEx(obj)
        For Each elem In Desktopx.Object("parent").Children
            elem.left = elem.left/var
            elem.top = elem.top/var
       
            elem.width = elem.width/var
            elem.height = elem.height/var   
       
            elem.SetFont "Arial", elem.fontsize/var, elem.fontbold, elem.fontitalic, elem.fontunderline, elem.fontstrikeout, 0
       
        Next
        Object.width = Object.width/var
        Object.height = Object.height/var
       
        Object.SetFont "Arial", Object.fontsize/var, Object.fontbold, Object.fontitalic, Object.fontunderline, Object.fontstrikeout, 0

        Object.left = Object.left + (((object.width*(var)) - Object.width)/2)
        Object.top = Object.top + (((object.height*(var)) - Object.height)/2)

End Sub

As you can see, I have the code set up such that when you mouse over the parent object, the object, as well as all of it's children grow bigger by a factor of whatever "var" represents (in this case 1.3). Furthermore, I have it set up such that when the parent object enlarges, the children still line up in the correct position relative to the size of the parent object.

 

Now for the problem;

When I apply this code, whenever I mouse over the parent, it does what it's supposed to do, but as soon as my cursor approaches one of the text objects, the parent object suddenly gets smaller (along with all of it's children) and then enlarges to the right size again.

Is there anyway to make it NOT do that? Or is this just a glitch in DesktopX..?

 

Thanks again.

 

 

 

homer1324
Reply #1 Sunday, May 17, 2009 2:38 AM

Anyone have ANY suggestions?

If this is the wrong place to post this, let me know....

 

 

(sorry for double post)

RomanDA
Reply #2 Monday, May 18, 2009 9:26 AM

i know whats happening.

go into all the text objects, etc and change their properties for "relation" and change the "activation" to "none" this will make it transparent to the mouse.

what is happening is that all objects are setup to have mouseover capabilities, and when you "stack" items on top of each other the mouse has to look at all the objects as it passes over them.   so when you make the parent object have a mouseover event it works as long as the mouse is "ON" the parent object, when you move over the text, its now ON the text, not the parent object.

So, unless you have some reason you want the text to be "clickable" then do as stated above, if you need items on the parent object to be clickable, or have mouseover effects then there is little that can be done about what your seein.

You should also change the parent object's "activation" to "rectangular area".  This makes it one big rectangle and not just the parts that are "visible".  this could help with the above as well.

 

Good luck.

homer1324
Reply #3 Tuesday, May 19, 2009 10:01 AM

RomanDA
i know whats happening.

go into all the text objects, etc and change their properties for "relation" and change the "activation" to "none" this will make it transparent to the mouse.

what is happening is that all objects are setup to have mouseover capabilities, and when you "stack" items on top of each other the mouse has to look at all the objects as it passes over them.   so when you make the parent object have a mouseover event it works as long as the mouse is "ON" the parent object, when you move over the text, its now ON the text, not the parent object.

So, unless you have some reason you want the text to be "clickable" then do as stated above, if you need items on the parent object to be clickable, or have mouseover effects then there is little that can be done about what your seein.

You should also change the parent object's "activation" to "rectangular area".  This makes it one big rectangle and not just the parts that are "visible".  this could help with the above as well.

 

Good luck.

 

None of that worked.

BUT

It did point me in the right direction;

 

'this is the name of the object in question
Const name = "weather_panel"
'this is the factor by which the object and all of its children will grow
Const var = 1.3



Dim temp
Sub Object_OnMouseEnterEx(Obj)
        If temp = 0 Then   
   
    For Each elem In Desktopx.Object(name).Children

        elem.left = elem.left*var
        elem.top = elem.top*var

       
        elem.width = elem.width*var
        elem.height = elem.height*var
         
        elem.SetFont "Arial", elem.fontsize*var, elem.fontbold, elem.fontitalic, elem.fontunderline, elem.fontstrikeout, 0
       
    Next
        Object.left = Object.left + (((object.width*(var)) - Object.width)/2)
        Object.top = Object.top - (((object.height*(var)) - Object.height)/2)
       
        Object.width = Object.width*var
        Object.height = Object.height*var
       
        Object.SetFont "Arial", Object.fontsize*var, Object.fontbold, Object.fontitalic, Object.fontunderline, Object.fontstrikeout, 0
    temp = 1
    End If   
End Sub
Sub Object_OnMouseLeaveEx(Obj)
        If System.CursorX < Object.Left Or System.CursorX > Object.Right Or System.CursorY > Object.Bottom Or System.CursorY < Object.Top Then
       
        For Each elem In Desktopx.Object(name).Children
            elem.left = elem.left/var
            elem.top = elem.top/var
       
            elem.width = elem.width/var
            elem.height = elem.height/var   
       
            elem.SetFont "Arial", elem.fontsize/var, elem.fontbold, elem.fontitalic, elem.fontunderline, elem.fontstrikeout, 0
       
        Next
        Object.width = Object.width/var
        Object.height = Object.height/var
       
        Object.SetFont "Arial", Object.fontsize/var, Object.fontbold, Object.fontitalic, Object.fontunderline, Object.fontstrikeout, 0

        Object.left = Object.left - (((object.width*(var)) - Object.width)/2)
        Object.top = Object.top + (((object.height*(var)) - Object.height)/2)
    temp = 0
    End If
   
End Sub

 

As you can see, the main differences here is that I cleaned up the code a bit and I added a checker to see if the mouse position has actually cleared the object's space before resizing.

 

I've tested this all over my desktop and it seems to work perfectly without any allignment issues (just make sure that if you have a text object, that the allignment is left and not right or center!!!)

Thanks for the help, and I hope this helps someone in the future!

 

sViz
Reply #4 Wednesday, May 20, 2009 4:03 PM

Ah, the old mouseover child = mouseaway from parent problem.

Here's another solution brought to you by Tiggz:

 

What you can do is to make the mouseleave event start a timer, and a mouseover event for any of the children kills the timer - if the timer fires, it does the relevant hiding then kills itself.

This serves the dual purpose of providing a delay for the hiding to allow for accidental slips of the mouse.

It would look something like this:

 

Code: vbscript
  1. Sub Object_OnMouseEnterEx(Obj)
  2.  object.KillTimer 1
  3.   'Followed by your expanding codes 
  4. End Sub
  5. Sub Object_OnMouseLeaveEx(Obj)
  6.     object.SetTimer 1,100
  7. End Sub
  8. 'Timer delay
  9. Sub Object_OnTimer1
  10.  smaller 'call shrinking function
  11.  object.KillTimer 1
  12. End Sub
  13. Function smaller
  14.  'Your shrinking codes here
  15. End Function
RomanDA
Reply #5 Wednesday, May 20, 2009 6:31 PM

nice

homer1324
Reply #6 Sunday, August 2, 2009 1:42 PM

hey so i've actually got an update on this issue; you can actually add a message to the mouse over states of the children objects which will broadcast a command to any object or even all objects at once.

Essentially, an easy non- script way to resolve this issue is to do make all the children object's mouse over state send a message to the parent object, to change it's state to "Mouse Over"

I've tested this and it works perfectly

Please login to comment and/or vote for this skin.

Welcome Guest! Please take the time to register with us.
There are many great features available to you once you register, including:

  • Richer content, access to many features that are disabled for guests like commenting on the forums and downloading skins.
  • Access to a great community, with a massive database of many, many areas of interest.
  • Access to contests & subscription offers like exclusive emails.
  • It's simple, and FREE!



web-wc01