Aligning buttons in column in Red - red

I am brand new to Red/Rebol. I love it so far, I am experimenting with the GUI system.
I am trying to align some buttons in a vertical column so to speak.
This is what I have so far
Red [ Title: "Editor" needs: 'view]
view [ size 800x600 title "Save Notes"
t: text ""
a: area 500x500 black
button "Click" [t/text: "Red is good !" ] return
text "" button "Close" [quit] return
text "" button "Save" [save %notes.dat a/text t/text "Saved"]
]
This is what it creates, which I have annotated with what I am trying to do:

Welcome to Red!
In the VID dialect, the default direction where the next element will be put, is by default horizontal (across), so that a return will go to the next column. If you switch the direction to vertical (using below), then the next element will go in the next row, staying in the same column. So it gives you:
Red [ Title: "Editor" needs: 'view]
view [ size 800x600 title "Save Notes"
t: text ""
a: area 500x500 black
below pad 10x0
button "Click" [t/text: "Red is good !" ]
text "hello" button "Close" [quit]
text "world" button "Save" [save %notes.dat a/text t/text "Saved"]
]
Note: I just put some text into your empty labels, so that we can see them in the layout, and how they affect the positionning of the buttons.
Have fun playing with it! ;-)

Related

How to add text under the heading in inline mode

enter image description here
I need to add text as shown in the picture above, but I don't understand how to implement it
my code:
def inline(inline_query):
markup = [
types.InlineQueryResultArticle(
number, language.warning,
types.InputTextMessageContent(language.warning_info)
)
]
bot.answer_inline_query(inline_query.id, markup)

Change position of a TreeView to the Panel from ActivityBar

I'm fully able to move my TreeView from the SideBar to the bottom panel (Problems, output, terminal...).
However, I'm uncertain how I would go about making my TreeView appear in the bottom panel by default. The documentation doesn't state anything about the bottom panel.
Any ideas?
I see the panel as an option for the viewContainer as in:
"contributes": {
"viewsContainers": {
"panel" : [ // instead of activityBar here
{
"id": "your virewContainer id",
"title": "your title",
"icon": "$(....)"
}
]
}
}
Found by using intellisense.

Summernote and customize "magic pen" (style) tool

I am using summernote in my project and i want customize style button with "magic pen" icon. In this button you can set h1-h6 or quotes, code(pre tag)....
There is my summernote toolbar settings:
toolbar: [
['style', ['style']],
['style', ['bold', 'italic', 'underline', 'clear']],
['view', ['fullscreen', 'codeview']],
['help', ['help']]
]
first style setting is for "magic pen" button (first from left on toolbar), second style is for bold italic... button group (second from left on toolbar).
So is there some possibility customize first style button with "magic pen" icon?
I need remove some options from there... h1, h5, quotes, code...
On internet i was find some solutions which not work:
StyleTags options (not toolbar):
styleTags:
['p', 'blockquote', 'pre']
Or specify first 'style':
toolbar: [
['style', ['blockquote', 'pre']],
but without success can anybody help?
Not sure if you got sorted with this but had this issue today, Summernote documentation wouldn't be the best but this worked for me and might help someone else out in the future.
$(document).ready(function() {
$('textarea[data-content~=summernote-content]').summernote({
height: 400,
toolbar: [
['style', ['style']],
['font', ['bold', 'italic', 'underline', 'clear']],
['help', ['help']]
],
styleTags: ['p', 'h1', 'h2', 'h3', 'h4', 'h5'],
});
});
So you just define the style as normal in the toolbar tags but then below it you specify the actual attributes you wish to show.

Should I use an event handler or actor for adding keyboard controls for a game

In Rebol3 Saphir, I am writing a game and I had been poking about with the event handler functionality as well as actors, and I was wondering whether it would be a better idea to use an event handler to take keyboard controls for the game or to add an actor into one of the GUI elements.
If I use an actor, on what level? I'm currently using an image! type for the screen. Can I add an actor to the root(layout) face so even if I click (give focus) to a button also on the GUI the focus will be off the image and it won't take keyboard controls.
Below is an example how you could do it...You might also use just the built-in keyboard shortcuts feature if you don't need key-up events. In such case see example with shortcut keys here: https://github.com/saphirion/documentation/blob/master/r3/r3-gui/examples/layouts/layout-15.r3
This version is modified to work with the current (09/26/13) release of R3-GUI
REBOL [
author: "cyphre#seznam.cz"
]
load-gui
;image for game screen
img: make image! 400x400
;just some example game object
game-object: context [
offset: 0x0
draw-block: [
pen red
fill-pen white
line-width 5
circle offset 20
]
move: func [
delta [pair!]
][
offset: offset + delta
img/rgb: black
;note: this is not optimal way how to render DRAW objects
;but I use image! here because the asking SO user uses image! as well
;better way is to just use DRAWING style for DRAW based graphics
draw img to-draw draw-block copy []
draw-face game-screen
;signal true move has been executed
return true
]
]
stylize [
;backup the original window style to be able call the original key actor
window-orig: window []
;override window style with our key actor
window: window [
actors: [
on-key: [
;execute our key controls prior to 'system' key handling
switch arg/type [
key [
;here you can handle key-down events
moved?: switch/default arg/key [
up [
game-object/move 0x-5
]
down [
game-object/move 0x5
]
left [
game-object/move -5x0
]
right [
game-object/move 5x0
]
][
false
]
]
key-up [
;here you can handle key-up events
]
]
;for example filter out faces that shouldn't get the system key events (for example editable styles)
unless all [
moved?
guie/focal-face
tag-face? guie/focal-face 'edit
][
;handle the system key handling
do-actor/style face 'on-key arg 'window-orig
]
]
]
]
]
view [
title "Custom keyboard handling (whole window)"
text "press cursor keys to move the box"
game-screen: image options [min-size: 400x400 max-size: 400x400]
text 400 "focus the field below and press to see these keys are filtered out, but other keys works normally"
field "lorem ipsum"
when [enter] on-action [
;initialize game object
game-object/move 200x200
set-face game-screen img
]
]
This version uses an as-of-yet unreleased version of R3-GUI:
REBOL [
author: "cyphre#seznam.cz"
]
;image for game screen
img: make image! 400x400
;just some example game object
game-object: context [
offset: 0x0
draw-block: [
pen red
fill-pen white
line-width 5
circle offset 20
]
move: func [
delta [pair!]
][
offset: offset + delta
img/rgb: black
;note: this is not optimal way how to render DRAW objects
;but I use image! here because the asking SO user uses image! as well
;better way is to just use DRAWING style for DRAW based graphics
draw img to-draw draw-block copy []
draw-face game-screen
;signal true move has been executed
return true
]
]
stylize [
;backup the original window style to be able call the original key actor
window-orig: window []
;override window style with our key actor
window: window [
actors: [
on-key: [
;execute our key controls prior to 'system' key handling
switch arg/type [
key [
;here you can handle key-down events
moved?: switch/default arg/key [
up [
game-object/move 0x-5
]
down [
game-object/move 0x5
]
left [
game-object/move -5x0
]
right [
game-object/move 5x0
]
][
false
]
]
key-up [
;here you can handle key-up events
]
]
;for example filter out faces that shouldn't get the system key events (for example editable styles)
unless all [
moved?
guie/focal-face
tag-face? guie/focal-face 'edit
][
;handle the system key handling
do-actor/style face 'on-key arg 'window-orig
]
]
]
]
]
view [
title "Custom keyboard handling (whole window)"
text "press cursor keys to move the box"
game-screen: image img options [min-size: 400x400 max-size: 400x400]
text 400 "focus the field below and press to see these keys are filtered out, but other keys works normally"
field "lorem ipsum"
when [enter] on-action [
;initialize game object
game-object/move 200x200
]
]

Make Firefox Panel fit content

I'm manually porting an extension I wrote in Chrome over to Firefox. I'm attaching a panel to a widget, and setting the content of that panel as an HTML file. How can I make the panel shrink and grow with the content? There's a lot of unsightly scroll bars and grey background right now.
var data = require("self").data;
var text_entry = require("panel").Panel({
width: 320,
height: 181,
contentURL: data.url("text-entry.html"),
contentScriptFile: data.url("get-text.js")
});
require("widget").Widget({
label: "Text entry",
id: "text-entry",
contentURL: "http://www.mozilla.org/favicon.ico",
panel: text_entry
});
Not setting the height property of the panel makes it quite tall.
You might want to check out this example that resizes the panel based on the document loaded. If you want to resize based on changes to the content size, at least on initial load:
https://builder.addons.mozilla.org/package/150225/latest/
( sorry for the delay in respinding, been afk travelling )