Re: [Win32Lib] Click on Label

new topic     » goto parent     » topic index » view thread      » older message » newer message

----- Original Message ----- 
From: "Juergen Luethje" <j.lue at gmx.de>
To: <EUforum at topica.com>
Subject: Re: [Win32Lib] Click on Label


> 
> 
> C. K. Lester wrote:
> 
> >> Can a label respond to an onClick event? (I searched the message
> >> archive and couldn't find the answer, which is odd. I thought I
> >> remember this coming up before.)
> >
> > Okay, no... (it's in the docs. sorry)
> >
> > So how do I simulate it? I need to be able to click on the label or "a"
> > label-lookalike control.
> 
> You could use the latest Arwen version, it has got a HyperText control.
> (I just can't remember who suggested to add such a control to Arwen.) smile
> 

A Hypertext controls implies that you can respond to clicks on specific
words/phrases which maybe highlighted in some manner. Is this what you need?
Otherwise, if its okay to just respond to a click anywhere in the text, then you
can use a simple child window.

Here is an extended example program...

--------------
include win32lib.ew 
without warning
integer MainWin
integer ChildWin                     

atom TColor

TColor = Red

-- Create a window and get it's ID.
MainWin =  createEx(Window, "Basic Window",0,10,20,200,100,0,0)
ChildWin =  createEx(Window, "Child Window",MainWin,10,20,88,20,
            {WS_CHILD,WS_CLIPSIBLINGS,WS_VISIBLE},0)
                                                                       

procedure Paint_ChildWin(integer self, integer event, sequence parms) 
    sequence lSize
    sequence lText
    sequence lPos
    
    -- Build the text to display.
    lPos = getPointerPos()
    lText = sprintf("%s %d %d", {getText(ChildWin), lPos[1], lPos[2]})
    
    -- Resize the control to hold the text.
    lSize = getTextExtent(ChildWin, lText)+4 
    setCtlSize(ChildWin, lSize[1], lSize[2])
    
    -- Blank of the control with its BG Color
    setWindowBackColor(ChildWin, White)      
    
    -- Draw its border
drawLines(ChildWin, {BrightWhite,
    {0,0,lSize[1]-1,0},{lSize[1]-1,lSize[2]-1},
                         Black,{0,lSize[2]-1},{0,0}})
                         
    -- Set the text color and draw the text.                         
    setTextColor(ChildWin, TColor)
    wPuts({ChildWin, 2, 2 }, lText)
    
end procedure
setHandler(MainWin, w32HPaint, routine_id("Paint_ChildWin")) 

procedure Click_ChildWin(integer self, integer event, sequence parms) 
    if TColor = Red then
        TColor = Blue
    else
        TColor = Red
    end if
    
    Paint_ChildWin(self, w32HPaint, {})
end procedure
setHandler(ChildWin, w32HClick, routine_id("Click_ChildWin")) 

-- Start to application running, using 
WinMain( MainWin, Normal)  

--------------
-- 
Derek

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu