Jump to content

"onClientMouseEnter/Exit events questions


G-Stefan

Recommended Posts

Hi guys,my name is Galea

Problem(s):The

"onClientMouseEnter" 

works just once and

"onClientMouseExit" 

doesnt work for me

Code:

  
local mainFont = guiCreateFont(...) 
local sW,sH = guiGetScreenSize() 
  
  
  
function mainElements() 
    mWindow = guiCreateStaticImage(0,0,sW,sH,"...",false) 
     
    rButton = guiCreateLabel(0,sH - 240,400,50,"...",false,mWindow) 
    guiSetFont(rButton,mainFont) 
    guiLabelSetColor(rButton,255,0,0) 
     
    lButton = guiCreateLabel(0,sH - 170,400,50,"...",false,mWindow) 
    guiSetFont(lButton,mainFont) 
    guiLabelSetColor(lButton,255,255,0) 
     
    cButton = guiCreateLabel(0,sH - 100,400,50,"...",false,mWindow) 
    guiSetFont(cButton,mainFont) 
    guiLabelSetColor(cButton,0,0,255) 
     
    addEventHandler("onClientMouseEnter",rButton,buttonEnter,false) 
    addEventHandler("onClientMouseEnter",lButton,buttonEnter,false) 
    addEventHandler("onClientMouseEnter",cButton,buttonEnter,false) 
     
     
    --addEventHandler("onClientMouseExit",lButton,buttonLeave,false) 
    --addEventHandler("onClientMouseExit",cButton,buttonLeave,false) 
     
end 
addEventHandler("onClientResourceStart",getRootElement(),mainElements) 
  
function buttonEnter() 
    playSound("...") 
    local gX,gY = guiGetPosition(source,false) 
    gSelect = guiCreateStaticImage(gX,gY,sW,50,"...",false,mWindow) 
    guiSetAlpha(gSelect,0.25) 
     
    addEventHandler("onClientMouseExit",source,buttonLeave,false) 
end 
  
function buttonLeave() 
    guiSetAlpha(gSelect,0) 
end 
addEventHandler() 

Link to comment
      
    local mainFont = guiCreateFont(...) 
    local sW,sH = guiGetScreenSize() 
      
      
      
    function mainElements() 
        mWindow = guiCreateStaticImage(0,0,sW,sH,"...",false) 
        
        rButton = guiCreateLabel(0,sH - 240,400,50,"...",false,mWindow) 
        guiSetFont(rButton,mainFont) 
        guiLabelSetColor(rButton,255,0,0) 
        
        lButton = guiCreateLabel(0,sH - 170,400,50,"...",false,mWindow) 
        guiSetFont(lButton,mainFont) 
        guiLabelSetColor(lButton,255,255,0) 
        
        cButton = guiCreateLabel(0,sH - 100,400,50,"...",false,mWindow) 
        guiSetFont(cButton,mainFont) 
        guiLabelSetColor(cButton,0,0,255) 
        
        addEventHandler("onClientMouseEnter",rButton,buttonEnter,false) 
        addEventHandler("onClientMouseEnter",lButton,buttonEnter,false) 
        addEventHandler("onClientMouseEnter",cButton,buttonEnter,false) 
        
        
        --addEventHandler("onClientMouseExit",lButton,buttonLeave,false) 
        --addEventHandler("onClientMouseExit",cButton,buttonLeave,false) 
        
    end 
    addEventHandler("onClientResourceStart",getRootElement(),mainElements) 
      
    function buttonEnter() 
        playSound("...") 
        local gX,gY = guiGetPosition(source,false) 
        gSelect = guiCreateStaticImage(gX,gY,sW,50,"...",false,mWindow) 
        guiSetAlpha(gSelect,0.25) 
    end 
      
    function buttonLeave() 
    if source == rButton or source == lButton or source == cButton then 
        guiSetAlpha(gSelect,0) 
    end 
    end 
     
    addEventHandler("onClientMouseExit",root,buttonLeave,false) 
   -- addEventHandler() 

Link to comment
      
    local mainFont = guiCreateFont(...) 
    local sW,sH = guiGetScreenSize() 
      
      
      
    function mainElements() 
        mWindow = guiCreateStaticImage(0,0,sW,sH,"...",false) 
        
        rButton = guiCreateLabel(0,sH - 240,400,50,"...",false,mWindow) 
        guiSetFont(rButton,mainFont) 
        guiLabelSetColor(rButton,255,0,0) 
        
        lButton = guiCreateLabel(0,sH - 170,400,50,"...",false,mWindow) 
        guiSetFont(lButton,mainFont) 
        guiLabelSetColor(lButton,255,255,0) 
        
        cButton = guiCreateLabel(0,sH - 100,400,50,"...",false,mWindow) 
        guiSetFont(cButton,mainFont) 
        guiLabelSetColor(cButton,0,0,255) 
        
        addEventHandler("onClientMouseEnter",rButton,buttonEnter,false) 
        addEventHandler("onClientMouseEnter",lButton,buttonEnter,false) 
        addEventHandler("onClientMouseEnter",cButton,buttonEnter,false) 
        
        
        --addEventHandler("onClientMouseExit",lButton,buttonLeave,false) 
        --addEventHandler("onClientMouseExit",cButton,buttonLeave,false) 
        
    end 
    addEventHandler("onClientResourceStart",getRootElement(),mainElements) 
      
    function buttonEnter() 
        playSound("...") 
        local gX,gY = guiGetPosition(source,false) 
        gSelect = guiCreateStaticImage(gX,gY,sW,50,"...",false,mWindow) 
        guiSetAlpha(gSelect,0.25) 
    end 
      
    function buttonLeave() 
    if source == rButton or source == lButton or source == cButton then 
        guiSetAlpha(gSelect,0) 
    end 
    end 
     
    addEventHandler("onClientMouseExit",root,buttonLeave,false) 
   -- addEventHandler() 

it doesnt work,i think is because gSelect reders in front of the labels and this creates a little bug,i'll try to solve it by myself

Link to comment

I solved the code

Here is the new code,which is working with no problems:

  
local mainFont = guiCreateFont("---",40) 
local sW,sH = guiGetScreenSize() 
local gSelect 
  
function theBackground() 
    dxDrawImage(0,0,sW,sH,"---") 
end 
addEventHandler("onClientRender",root,theBackground) 
  
function mainElements() 
  
    showCursor(true) 
    showChat(false) 
    showPlayerHudComponent("all",false) 
  
    rButton = guiCreateLabel(0,sH - 240,400,50,"---",false) 
    guiSetFont(rButton,mainFont) 
    guiLabelSetColor(rButton,255,0,0) 
     
    lButton = guiCreateLabel(0,sH - 170,400,50,"---",false) 
    guiSetFont(lButton,mainFont) 
    guiLabelSetColor(lButton,255,255,0) 
     
    cButton = guiCreateLabel(0,sH - 100,400,50,"---",false) 
    guiSetFont(cButton,mainFont) 
    guiLabelSetColor(cButton,0,0,255) 
     
    addEventHandler("onClientMouseEnter",rButton,buttonEnter,false) 
    addEventHandler("onClientMouseEnter",lButton,buttonEnter,false) 
    addEventHandler("onClientMouseEnter",cButton,buttonEnter,false) 
end 
addEventHandler("onClientResourceStart",root,mainElements) 
  
function buttonEnter() 
    playSound("---") 
    local gX,gY = guiGetPosition(source,false) 
    gSelect = guiCreateStaticImage(gX,gY,sW,50,"---",false) 
    guiMoveToBack(gSelect) 
    guiSetAlpha(gSelect,0.25) 
end 
  
function bLeave(aX,aY) 
    destroyElement(gSelect) 
end 
addEventHandler("onClientMouseLeave",getRootElement(),bLeave) 
  

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...