Newbie: Help with image buttons (View)
[1/15] from: kimm2::mcmaster::ca at: 26-Sep-2002 2:12
Hi, I'm trying to make a cell phone demo for the computer which involves having the button on the phones to become active. For example... I want the demo to be able to have clickable 'numbers' to dial a phone number, and a clickable 'send' button to emulate placing a call. I run into a problem because, the phone's buttons are not rectangular in shape. I made the phone's buttons into separate images and overlayed them onto the main image of the phone, but the REBOL buttons are rectangular in shape, and have a shadow/border. Is there a way either to: 1) Make the buttons in REBOL/VIEW, have no border and no effect when the mouse clicks on it? (Buttons usually sink when clicked on). 2) Make a coordinate system over the image of the phone and detecting mouse clicks over that coordinate, particularily over buttons? Thanks! Matt
[2/15] from: anton:lexicon at: 26-Sep-2002 20:09
This might help you: view layout [ style my-button button 40x40 edge none colors reduce [blue red] font-size 20 my-button "1" my-button "2" ] You could also use some images: ... my-button %image-up.png %image-down.png ...
[3/15] from: carl:cybercraft at: 27-Sep-2002 0:35
On 26-Sep-02, Matthew Kim wrote:
> I'm trying to make a cell phone demo for the computer which involves > having the button on the phones to become active.
<<quoted lines omitted: 8>>> 1) Make the buttons in REBOL/VIEW, have no border and no effect when > the mouse clicks on it? (Buttons usually sink when clicked on).
If that's the behaviour you want, just uses images instead of buttons. ie... rebol  ; Create two images... img-1: to-image layout [backdrop pink text "Image 1"] img-2: to-image layout [backdrop yellow text "Image 2"] view layout [ output: field "Click on images" image img-1 [output/text: "Image 1" show output] image img-2 [output/text: "Image 2" show output] ] Other styles such as images can have a block which will be evaluated when the style is clicked on - it's not just the obvious ones like buttons that you can do this with. Hope that answers your question.
> 2) Make a coordinate system over the image of the phone and > detecting mouse clicks over that coordinate, particularily over > buttons? > Thanks! > Matt
-- Carl Read
[4/15] from: kimm2:mcmaster:ca at: 26-Sep-2002 10:40
Thanks Carl! That's exactly what I needed! A follow up question... Is there a way to change the mouse arrow into a hand, when the user floats over a clickable image/button? -Matt
[5/15] from: greggirwin:mindspring at: 26-Sep-2002 9:36
Hi Matt, << Is there a way to change the mouse arrow into a hand, when the user floats over a clickable image/button? >> REBOL doesn't allow any cursor control at this time. You could work around it for specific OSs, but a common alternative is to have the button itself display an effect of some kind when the mouse is over it, like TEXT styles do when they have an action associated with them. --Gregg
[6/15] from: kimm2:mcmaster:ca at: 26-Sep-2002 14:53
I seem to be having a problem with 'fields'. I have a 'field' covering the window of the cell phone, where users will be able to type 'text messages', and also where menus will be displayed. However, the text doesn't seem to wrap around, instead it continues on in a straight line. If I use a 'text' box, then it DOES wrap around... However, users's can't input messages. Secondly... How do you do a line break within a string? Thanks! Matt
[7/15] from: carl:cybercraft at: 27-Sep-2002 9:29
On 27-Sep-02, Matthew Kim wrote:
> I seem to be having a problem with 'fields'. > I have a 'field' covering the window of the cell phone, where users
<<quoted lines omitted: 3>>> If I use a 'text' box, then it DOES wrap around... However, users's > can't input messages.
Use 'wrap... view layout [field 50x100 "The rain in Spain is wet..." wrap] Though 'area instead of 'field is normally used when you want a multi-line box. You still need wrap to get word-wrapping though.
> Secondly... > How do you do a line break within a string?
abc^/def or "abc^(line)def". The "^" is the escape character, so, when used at the Console...
>> print "abc^/def"
>> print "abc^(line)def"
>> print "abc^-def"
>> print "abc^(tab)def"
>> print "abc^^def"
>> print "abc^(41)def"
abcAdef and so on. The number in the last one there is in hex, not decimal. Look in the Core Guide (it's on the REBOL site) in the Other Values section for Character to see the other escape characters. -- Carl Read
[8/15] from: kimm2:mcmaster:ca at: 26-Sep-2002 23:40
Thanks for the great advice Carl! Now... On to my next problem... This is my first attemp using View and I'm pretty sure I'm not getting this done the best way possible. However... I seem to have pinpointed the problem to a 'foreach' loop. I have a function called: cellphone: layout [ ... output: check "1" "test" ... ] Within this function, it calls another function: check: layout [number word][ ... foreach ... ... ] I seem to get the following error. It seems to be internal with the system, because I have no code resembling this in my program: ** Script Error: Invalid path value: view ** Where: evt-func ** Near: if all [ system/view/focal-face event/type = 'down not within? event/offset win-offset? system/view/focal-face system/view/focal-face/size system/view/focal-face/dirty? ] [ fac: system/view/focal-face unfocus do-face fac none fac/dirty?: none ] event
[9/15] from: anton:lexicon at: 27-Sep-2002 14:19
Show us all your code, we will disect and examine. Anton.
[10/15] from: carl:cybercraft at: 27-Sep-2002 21:17
On 27-Sep-02, Matthew Kim wrote:
> Thanks for the great advice Carl! > Now... On to my next problem... This is my first attemp using View
<<quoted lines omitted: 7>>> ... > ]
Note that layout's are objects, not functions. You can see this by entering the following in the Console...
>> lo: layout [text "Hello"] >> type? :lo
>> fun: func [a][print ["That was" a "!!!"]] >> type? :fun
== function! (The reason for the colons in front of the words when type? is used is to prevent them being evaluated, as the function would be in the above.) View is also a function, as is layout...
>> type? :view
>> type? :layout
== function! and so what happens with... view layout [...] is that layout turns the block into an object and then view parses the object, displaying it as a window. So I'm afraid it's back to the drawing board with the following Matthew...
> Within this function, it calls another function: > check: layout [number word][ > ... > foreach ... > ... > ]
As 'layout used like that doesn't make sense in REBOL. 'func instead of 'layout would, ('check would then be a function), but I'm not sure what you're trying to do with it in the 'cellphone layout, so I think you'll need to explain that a bit more for us to sort this out. -- Carl Read
[11/15] from: kimm2:mcmaster:ca at: 28-Sep-2002 12:17
Can I do this? Withint the layout, I have buttons. When the button is triggered, it sends off to a function (process_msg) for processing. Ex. cellphone: layout [ ... image left_button [ output: process_msg var1 var2 ... ] ... ]
[12/15] from: kimm2:mcmaster:ca at: 28-Sep-2002 12:32
Currently the entire program is structured as follows: process_msg: func [var1 var2][ ... foreach... [ if/else ... [ ... ] ] return x ] layers: func [var1 var2][ ... return x ] cellphone: layout [ ... image left_button [ output1: layers var1 var2 ... if flag == 1 [ output2: process_msg var1 var2 ] ] ... ] view cellphone ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ With "flag = 0", everything seems to work fine. When the flag is changed to "1", the error arises when the "foreach" loop within the "process_msg" function is called.
[13/15] from: greggirwin:mindspring at: 28-Sep-2002 13:43
Hi Matthew, When you have a bug in your code, it's best if you can post the actual code to the list because it's hard for anyone to know exactly what might be happening in different parts of the code, etc. There are some awesome people on this list. Given a piece of almost-working code, they can generally spot the problems very quickly and get you on track. --Gregg
[14/15] from: greggirwin:mindspring at: 28-Sep-2002 13:40
Hi Matthew, << Can I do this? >> Have you tried it? :) It should work just fine, but don't be afraid to play with things and run them. It's hard to hurt anything unless you're writing a file deletion utility and run it live without security or something. :) --Gregg
[15/15] from: anton:lexicon at: 29-Sep-2002 12:36
Matthew Kim, Show us at least the error message. If you don't want to also show us the code, I recommend diagnosing the error by printing some debug info in your process_msg function: process_msg: func [var1 var2][ ?? var1 ?? var2 ... ] Run the program again to see the values of var1 and var2. Then you can play around with foreach in the console, using the values for var1 and var2 that you saw. Anton.
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted