Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Button en-/disabling revisited

 [1/5] from: kpeters:otaksoft at: 26-Aug-2007 17:59


I am back to playing with my button dis-/enabling function. Taking Gabriele's last post on the topic into (my limited) consideration, I have it partially working. Disabling works, but enabling fails. As far as I understand, the problem may be that Rebol stores butt/colors/1 in user-data as a word..? If so, how would I cast that to a tuple? Or am I totally off? Thanks, Kai rebol[] disable: func[ butt [object!] flag [logic!]] [ either flag [ butt/user-data: butt/colors/1 butt/colors: [ gray ] butt/color: gray ] [ butt/color: butt/user-data butt/colors: [ butt/user-data ]] show butt ] scr: center-face layout [ goldie: btn 150 gold "Enable lemon" [ disable lemon false ] lemon: btn 150 yellow "Click me" 150 [ disable lemon true ] colors [ yellow ] ] unview/all view scr ;halt

 [2/5] from: santilli:gabriele:gmai:l at: 27-Aug-2007 10:51


2007/8/27, Kai Peters <kpeters-otaksoft.com>:
> [ butt/user-data: butt/colors/1 butt/colors: [ gray ] butt/color:
butt/colors: reduce [gray gray] (Just one gray will work too because it can't be clicked, but better to be safe :) HTH, Gabriele.

 [3/5] from: kpeters:otaksoft at: 27-Aug-2007 12:43


Thanks, Gabriele ~ that was just the hint I needed - things are looking a lot better now, although another problem reared its ugly head: As you see, I have added a line to prevent disabling from happening twice (as it screws up the button colors for good). I would expect to see the alert the second time I press button 'b1 - it does, however, only show upon the third button press.... Does anyone have a clue as to why? TIA, Kai disable: func[ butt [object!] flag [logic!]] [ if all [ flag butt/user-data = gray ][ alert "gray" exit ] ; don't disable twice - screws up colors ; either flag [ butt/user-data: butt/colors/1 butt/colors: reduce [ gray gray ] butt/color: gray show butt butt/feel: none ] [ butt/feel: svvf/btn butt/color: butt/user-data butt/colors: reduce [ butt/user-data butt/user-data ] show butt ] ] scr: center-face layout [ b1: btn 150 sky "Disable lemon" [ disable lemon true ] b2: btn 150 gold "Enable lemon" [ disable lemon false ] lemon: btn 150 yellow "Click me" [ flash "Hi bud!" ] colors [ yellow yellow ] ] view scr

 [4/5] from: santilli:gabriele:gm:ail at: 28-Aug-2007 8:16


2007/8/27, Kai Peters <kpeters-otaksoft.com>:
> disable: func[ butt [object!] flag [logic!]] [ > if all [ flag butt/user-data = gray ][ alert "gray" exit ] ; don't
user-data is not gray when disabled, it holds the original color. So, you need to check if face/color is gray (or face/colors/1). Of course this does not work if the button was gray in the first place, but I guess you're not doing that. HTH, Gabriele.

 [5/5] from: kpeters:otaksoft at: 28-Aug-2007 21:39


Thanks Gabriele ~ that should have been so obvious it almost hurts to think about it! Arghh! Kai On Tue, 28 Aug 2007 08:16:49 +0200, Gabriele Santilli wrote: