LinkButton.st
changeset 5045 50eb267766b2
parent 4987 82bb0a9fecdb
child 5067 3a0ae394e2a2
child 5096 45da9082a826
equal deleted inserted replaced
5044:f8c330427edc 5045:50eb267766b2
     1 "{ Encoding: utf8 }"
       
     2 
       
     3 "{ Package: 'stx:libwidg2' }"
     1 "{ Package: 'stx:libwidg2' }"
     4 
     2 
     5 "{ NameSpace: Smalltalk }"
     3 "{ NameSpace: Smalltalk }"
     6 
     4 
     7 Button subclass:#LinkButton
     5 Button subclass:#LinkButton
    14 !LinkButton class methodsFor:'documentation'!
    12 !LinkButton class methodsFor:'documentation'!
    15 
    13 
    16 documentation
    14 documentation
    17 "
    15 "
    18     Looks like a Label, but behaves like a button with individually clickable text components.
    16     Looks like a Label, but behaves like a button with individually clickable text components.
    19     Can be used to create html-page-look-alike links in a view.
    17     Can be used to create html-page-look-alike links in a view,
       
    18     especially to make label-looking action buttons.
    20 
    19 
    21     [author:]
    20     [author:]
    22         cg (cg@CG-VOSTRO)
    21         cg (cg@CG-VOSTRO)
    23 
    22 
    24     [instance variables:]
    23     [instance variables:]
   127      For display, the label strings are drawn as one concatenated string (add separating spaces, if you have to).
   126      For display, the label strings are drawn as one concatenated string (add separating spaces, if you have to).
   128      When clicked on a string, the corresponding action is called"
   127      When clicked on a string, the corresponding action is called"
   129 
   128 
   130     labelsAndActions := aCollectionOfAssociations.
   129     labelsAndActions := aCollectionOfAssociations.
   131     self label:((aCollectionOfAssociations collect:[:assoc | assoc key]) asStringWith:'')
   130     self label:((aCollectionOfAssociations collect:[:assoc | assoc key]) asStringWith:'')
       
   131 !
       
   132 
       
   133 level:anInteger
       
   134     enterLevel := leaveLevel := onLevel := offLevel := level := anInteger.
       
   135     margin := level abs.
   132 ! !
   136 ! !
   133 
   137 
   134 !LinkButton methodsFor:'initialization'!
   138 !LinkButton methodsFor:'initialization'!
   135 
   139 
   136 allViewBackground:something if:condition
   140 allViewBackground:something if:condition
   240     "/ intentionally ignored
   244     "/ intentionally ignored
   241     ^ self
   245     ^ self
   242 !
   246 !
   243 
   247 
   244 drawStringLogo:aString x:x y:y
   248 drawStringLogo:aString x:x y:y
   245     "redefined to draw the part under the mouse pointer with an underined emphasis"
   249     "redefined to draw any anchor under the mouse pointer with an underlined emphasis"
   246 
   250 
   247     |str entered mousePoint start len emphasis|
   251     |str entered mousePoint start len emphasis|
   248 
   252 
   249     mousePoint := controller lastMousePoint.
   253     mousePoint := controller lastMousePoint.
   250     entered := controller entered.
   254     entered := controller entered.