Continuing the list with checkboxes - org-mode

Suppose that the cursor is currently after the word "bread" at the end of this piece:
* TODO Week1 [/]
SCHEDULED: <2015-08-09 Sun>
- [ ] Buy bread
When I press Alt-Enter, it adds a list item, but not a checkbox. Can I modify this behavior, so that a list that starts with a checkbox would continue with checkboxes as well?

Related

How to continue a list item after a sublist

I would like to have some descriptive text in a list item after a sublist.
How to achieve that in Asciidoc?
Here is the structure I would like to have:
A list item of the main list
Then a sublist with some list item
Just another sublist item to give the sublist sense
And after the sublist some more descriptive text.
A subsequent item of the main list.
What I have tried:
Starting point:
* A list item of the main list
** Then a sublist with some list item
** Just another sublist item to give the sublist more sense
*And after the sublist some more descriptive text.*
* A subsequent item of the main list.
The comment //-- ends the main list. So it is not helpful at this point.
Stuff like multiple newlines does not help to end a sublist.
In Orgmode the following code gives the desired layout:
- A list item of the main list
- Then a sublist with some list item
- Just another sublist item to give the sublist more sense
*And after the sublist some more descriptive text.*
- A subsequent item of the main list.
See attaching blocks to an ancestor list.
For example:
* A list item of the main list
+
--
** Then a sublist with some list item
** Just another sublist item to give the sublist more sense
--
+
*And after the sublist some more descriptive text.*
* A subsequent item of the main list.

Red vid How focus changed from one field to another with press enter

View [
f1: field focus
f2: field
]
When run this code cursor get focus in f1
But I want to press enter and focus will be in f2.
How can I do that?
From inside a on-enter handler, you need to change the selected facet of the window face (just the parent face in this case) to point to the face you want to focus on. So your code becomes:
view [ f1: field focus on-enter [face/parent/selected: f2] f2: field ]
If you need to change focus often, you can define a convenient shortcut function:
set-focus: function [face [object!]][
p: face/parent
while [p/type <> 'window][p: p/parent]
p/selected: face
]
view [ f1: field focus on-enter [set-focus f2] f2: field ]
Red/View will provide a built-in set-focus function in future versions, so you won't have to define it in your own code.

Listbox multiple selection matlab

I created a listbox and enabled multiple selections. My listbox contain numbers from 1 to 10. When I select 3, 1, and 8, the function always put my selections in alphabetical order (1,3,8). Is there any way I could make it not put my selection in alphabetical order? So if I select 3, 1, and 8 the output of my selection is 3, 1, 8.
Thank you.
For the purpose of this answer I'm assuming you're using matlab-hg2.
From the docs for uicontrol:
'listbox' ... The Value property stores the row indexes of currently selected list box items, and is a vector value when you select multiple items. After any mouse button up event that changes the Value property, MATLAB evaluates the list box's callback routine. To delay action when multiple items can be selected, you can associate a "Done" push button with the list box. Use the callback for that button to evaluate the list box Value property.
From the above we learn that the information on the selected lines is returned in Value. From there, it's a matter of keeping track of what's selected. This can be quite easily done using a persistent variable inside the listbox' Callback as shown in the following example:
function LISTBOX_EXAMPLE
hFig = figure('Units','Pixels','Position', [200 200 100 200],'Menubar','none');
uicontrol(hFig, ...
'Style', 'listbox',...
'Units','Pixels',...
'Position', [20 20 80 150],...
'Max',3,...
'Min',0,...
'String',num2cell(1:10),...
'Callback',#selectionCallback);
function selectionCallback(hObject,~)
persistent previouslyChosenItems
%// Elements were added:
if numel(previouslyChosenItems) < numel(hObject.Value)
previouslyChosenItems = union(previouslyChosenItems,hObject.Value,'stable');
%// Elements were removed:
elseif numel(previouslyChosenItems) > numel(hObject.Value)
previouslyChosenItems = intersect(previouslyChosenItems,hObject.Value,'stable');
%// A different element was selected (single element):
elseif numel(previouslyChosenItems) == numel(hObject.Value) && numel(hObject.Value)==1
previouslyChosenItems = hObject.Value;
end
disp(['Currently selected items (in order): ' num2str(previouslyChosenItems(:)')]);
end
end
Example output:
Currently selected items (in order): 7
Currently selected items (in order): 3
Currently selected items (in order): 3 9
Currently selected items (in order): 3 9 1
Then it's up to you to assign the value of previouslyChosenItems somplace useful.

Selecting a different record in List View via Script

I have a table in Filemaker 11 which has fields: thingID, infoNumber (#), itemHistory. infoNumber displays the order in which we think the item history's happened (sometimes this is incorrect and needs to be rearranged).
thingID, #, itemHistory
Thing 1, 1, was with Adam
Thing 1, 2, was with Claire
Thing 1, 3, was with Ben
Thing 1, 4, was with Dave
I display these in a List View (ordered by infoNumber asc), and a user realises that it actually went "1,3,2,4", I want to have up and down arrows visible in order for users to switch them, i.e. clicking on the up arrow on the record with infoNumber=3 will set it to 2 and the old infoNumber=2 will be set as 3.
How can I write a script to switch these when the user clicks on a button in a list view?
My idea:
Set Variable[$clickedDown, infoNumber] #the record we click on's infoNumber
If [ $clickedDown != 1 ]
Set Field [ infoNumber, clickedDown -1 ]
# But how do I move to the record with infoNumber = clickedDown-1 ??
End If
The way I have done this, is to do several Finds, here is my solution for going one way.
# First you've clicked on something, record its current infoNumber
Set Variable [ $infoNumber, infoNumber ]
# Use -2 (arbitrary) as a temporary place holder
Set Field [ infoNumber = -2]
Error Capture [ On ]
Perform Find [ thingID = $thingID, infoNumber = $infoNumber - 1 ]
If [ Get (LastError = 401) ]
# No results then just re-search temporary and set it back to what it
was
Perform Find [ thingID = $thingID, infoNumber = -2 ]
Set Field [ infoNumber, $infoNumber ]
Else
Set Field [ infoNumber, $infoNumber ]
Perform Find [ thingID = $thingID, infoNumber = -2 ]
Set Field [ infoNumber, $infoNumber -1 ]
End If
# Go back to layout you were in before
I would be interested to know if there was a better way!
You could do this by using relationships. Create a new table occurrence (say, History Previous) and link it to the list layout's table occurrence (say, History) with the following predicates:
History::ThingID = History Previous::ThingID
History::infoNumber > History Previous::infoNumber
Sort the relationship by History Previous::infoNumber, descending.
This will provide you with a set of related History records that appear earlier in the list for the relevant Thing. The first record will be the immediately previous one, thanks to the sorting.
Now, when you run the script, you can:
If [ Count ( History Previous::ThingID ) > 0 ]
Set Variable [ $infoNumber, History Previous::infoNumber ]
Set Field [ History Previous::infoNumber, History::infoNumber ]
Set Field [ History::infoNumber, $infoNumber ]
End If
Note that, although the History Previous relationship may refer to multiple records, you can rely on the relationship sorting to provide you with access to the first record, both when getting data from it (in the Set Variable step) and setting data into it (in the first Set Field step).

Setting up some properties for a combobox (scroll, edit, jump)

There are 3 properties that I want to set for some VBA form comboboxes and I don't know if it's possible.
I don't want to let the combobox editable. Right now if the user types something in it that it submits the form it will send that value... I want to let him choose only from the values I added in the Combobox.
I want to make the list of items in the combobox scroll-able. Right now I'm able to scroll through the list if I use the scroll-bar but I don't know why I can't scroll with the mouse scroll.
And I want to jump to some item if I start typing. Let's say I have the months of the year in one combobox... if I start to type mar I want it to jump to march. I know that for the html forms this properties is by default but I don't know about VBA forms...
Thanks a lot
Of the behaviours you want, some are possible with settings on the Combo, others you will need to code
List of Months: Put a list of entries on a (hidden) sheet and name the range. Set .RowSource to that range
Match as you type: Set properties .MatchEntry = fmMatchEntryComplete and .MatchRequired = True
Reject non list entries: A Combo with these settings will allow you to type an invalid entry, but will reject it with an error message popup when you commit. If you want to silently reject invalid data as you type, you will need to code it.
If you want the selected value returned to a sheet, set .ControlSource to a cell address (preferable a named range)
By "...scroll with the mouse scroll..." I assume you mean the mouse wheel. Unfortunatley Forms don't support mouse wheel scroll. You will have to code it yourself. There is a Microsoft patch for this at here (not tried it myself yet)
Sample code to silently reject invalid entries
Private Sub cmbMonth_Change()
Static idx As Long
Dim Match As Boolean
Dim i As Long
If cmbMonth.Value = "" Then Exit Sub
If idx = 0 Then idx = 1
i = idx
Match = False
For i = 0 To cmbMonth.ListCount
If cmbMonth.List((i + idx - 1) Mod cmbMonth.ListCount) Like cmbMonth.Value & "*" Then
cmbMonth.ListIndex = (i + idx - 1) Mod cmbMonth.ListCount
Match = True
Exit For
End If
Next
If Not Match Then
cmbMonth.Value = Left(cmbMonth.Value, Len(cmbMonth.Value) - 1)
End If
End Sub
Set the propertie MatchEntry of combobox to 1 (fmMatchEntryComplete) and MatchRequired to true for example
combobox1.MatchEntry=1
combobox1.MatchRequired=True
[]'s