Document based app: which is the key window? - swift

The code for the app is here (the Raiseman folder contains the files for the project):
https://github.com/bignerdranch/cocoa-programming-for-osx-5e/tree/master/Chapter%2011%20-%20Undo/RaiseMan
Each Document(window?) contains an NSTableView and two buttons:
The app uses an ArrayController to manage an array of Employees in the Document class, and the buttons add or remove Employees from the array.
I notice that if I click the Add Employee button and start editing the Employee's name in the NSTableView, and then before hitting Return to end editing, if I click on File>New to create a second Document, then click on Add Employee in the second Document, then edit the Employee's name and hit Return, the Return key is sent to the first Document, which ends the editing of the Employee's name in the first Document, while nothing changes in the second Document. Why is that? I expected the window that contains the button I clicked on to be the key window, and therefore the Return key would be sent to the second window.
If I hit Return again, then editing ends in the second Document.

Looks like a bug to me. The NSTableRowData object is observing NSControlTextDidEndEditingNotification for all objects, including the views in other windows.

Related

PowerApps Get Selected Item from Lookup to make a Button Visible at the Command line bar

I want a button from the command line bar to be visible or invisible depending on whether a record has been selected in the lookup field from the main form or not.
If no record has been selected, then the button should be displayed. Otherwise not.
For this problem, I want to use the Power Fx in PowerApps, but I haven't found a command yet, which shows me the content or something like that of the lookup field. Other field data types like text have worked without problems.
With Javascript, I already managed it without problems, but I would like to do it also in PowerFx if that should work.
Screenshot: https://i.stack.imgur.com/uqDJ6.png
The records come from the Table Company, where the attribute is Companyname.
Commands where I think they might work:
If([Selected Record];true;false);If(IsBlank([Selected Record]);true;false);If(IsBlankOrError([Selected Record]);true;false);If(IsEmpty([Selected Record]);true;false)
I guess there are 2 scenarios:
The Lookup form control element is a Dropdown with a Selected output property. Then your approach would work like If(IsBlankOrError(DataCardValue1.Selected),true,false)
If your form control element is a ComboBox then you could use If(CountRows(DataCardValue1.SelectedItems)>0,true,false) or the above described IsBlankOrError.

Product Catalogue side pane loads the entire data while adding the line item?

We have upgraded to sugar 8.0. In that, as a new feature, we have a product catalogue dashlet in the sidebar to add line item directly to quotes on the quote create view. Now if I click on the record in the product catalogue it loads the entire recordset to the quote line item. So it loads all the fields of that record that overwrites my default value that is set in the Quoted line item.
Whereas if I add the line item via the normal way(PFA) it is working fine.
while adding the line item I am setting the product status to Draft by default but whereas if I load it via the side panel then the status of the product catalogue gets overwritten in the quoted line item.
Thank You

Focus handling in SAPUI5

We have a requirement that of using a "tab" key in the table control to navigation across only input fields.
1. Every table row has atleast 6 to 8 fields - 2 of them are input fields and rest could be text,select etc.
2. By clicking tab i navigate across input fields in a row on clicking the last input field of a row i should move to the first input field of the next row.
I have the code for the following but i can see the focus method of the input control focuses the UI to subsequent input field of the input to be focused.
Jsbin - https://jsbin.com/lugesecuhe/edit?html,output
I tried to set styles like .sapMFocus and also document.getElementbyId().focus and they dont work either.
Can you suggest some pointers on this.
Thanks and Regards,
Veera
I have exactly the same problem and started looking into it. I found out that the navigation within the table is possible and performed by class sap.ui.core.delegate.ItemNavigation (at least in v1.26).
However, what I consider really non-intuitive:
On Mac (Chrome or Safari) you have to hold the ALT key while pressing TAB to cycle through the input fields of your table.
I haven't figured out how to do it on Windows
I checked in your JSBin example, somehow the fields get focused in a weird order. I have prepared my own example - http://jsfiddle.net/bgerth/x8h92mz8 - where you can cycle through the input fields row by row using Alt+Tab.
Update 1
I have found the blog SAPUI5 Table Navigation with Tab Key by Klaus Kronawetter which adds extra keyboard handling to a sap.ui.table.Table. I adapted his code for a sap.m.Table which you can find at http://jsfiddle.net/bgerth/os6r096y.
Update 2
After further investigation, I decided that the solution from update 1 above is too much hassle.
Instead, I adapted the class sap.ui.core.delegate.ItemNavigationmentioned above, which is internally employed by sap.m.ListBase. In essence, you can cycle through the input fields with up and down arrow keys.
I have prepared an example at http://jsfiddle.net/bgerth/0r9L30wd. The relevant code is
var fnPatchedItemNavigationsetItemDomRefs = sap.ui.core.delegate.ItemNavigation.prototype.setItemDomRefs;
sap.ui.core.delegate.ItemNavigation.prototype.setItemDomRefs = function setItemDomRefsPatched(aItemDomRefs) {
// 'this' is now the instance of sap.ui.core.delegate.ItemNavigation
jQuery.sap.log.debug("Patched version of sap.ui.core.delegate.ItemNavigation.setItemDomRefs");
var aInputFields = $(aItemDomRefs).find("input:enabled").get();
if (aInputFields[0]) {
// There is at least one enabled input field in this table
fnPatchedItemNavigationsetItemDomRefs.call(this, aInputFields);
} else {
fnPatchedItemNavigationsetItemDomRefs.call(this, aItemDomRefs);
}
}

delete selected item from text item

i have got multi lined text item like gridview in my forms project. i want to select an item and click delete button and the system must delete selected index but i didnt find the perfect function. it's not bind into the database so its not complicated i just want to delete the line from the text item. i tried to find the properties of the current record, i use some of loops but it didnt find the selected item index. does it have "selected item" function like c#, java. Or do i have to create a function to find selected item. which way is the best and how could i do that.
This code may help you(I didn't get a chance to test this) :
GO_BLOCK('Gridview_BLOCK_NAME');
GO_RECORD(record_index);
DELETE_RECORD;
GO_ITEM('block.delete_button');--if you want the cursor back to delete button

How to make a editor just output part of datas(eclipse plugin development)

I have some structured item want to show by editor, for example, the item's structure may like this {1,"hello"}, the "1" identity this item and the "hello" is item's content. now i want just show item's content to user, but the editor should know the item's identity, then, when one user select the content of an item, the editor should pass the item's identity to me, so i could know which item the user selected clearly(because the identity's function is just to distinguish items, so it should not be output to disturb users).
Any sugesstion is appreciated!
You can base your editor on a JFace viewer, where the viewers input (set by the setInput() method) is the collection of items you presented.
The content provider traverses this collection, and returns the correct items; finally the labelprovider returns only the content of the item.