Detect selected row with force touch watchkit - watchkit

Is it possible to detect selected row index with force touch? Did force touch in tableView current row is highlighted. But i can't take info about him when context menu appears. TableView method -didSelectRowAtIndex: not called with this event.

The only thing you can handle programmatically with the Force Touch is the Context Menu and this menu is associated with a specific controller, more information you will find following the link.
About the row highlighting: When you start tapping the system doesn't know what the real action is - the regular touch or the force one. So it is starting to highlight a specific area and only later find out what was the action.

Related

How to make pop-up data reflect selected record?

The case:
I have Activities as datamodel.
I have set Activities to have many-to-many relationship with themselves to represent a Parent / Child relationship.
I have set up an accordion widget. Each row of the accordion contain basic data about the Activity record + some buttons.
I have set one of the button's onClick functions to open a popup, which allows me to edit the Activity detail in a form.
When I click a different record from the same accordion, the form from the popup reflects the data in the selected record.
The problem:
I have nested accordions which represent the "Child" Activities of the Parent Activity.
I have also added a similar button, which opens a popup. I can open the popup, which targets the child records, but cannot make it open the specific record, from which I pressed the button.
So the popup open by default on the first child.
Please help - how can I make the popup change naturally to reflect the datasource / selected record of even nested datasources?
What I tried:
In order to try and make to popup work I have tried to set the datasource based on the relationship:
Activities: Sub_Activities(relation)
This works to the extent of showing the related items, but popup content does not dynamically change on clicking a different child record or clicking the button from a different child record.
In both cases what is shown is the first child record.
What I understand is that you have a set up in which you click a button and a popup shows. The popup should let you view/edit the record referenced in the row where the button is. If that is the case, then probably you already have almost everything setup for the next thing to work. First, add a string custom property to the popup and name it selectedKey. Then, on the onClick event of the button that opens the popup, add something like this:
var key = widget.datasource.item._key;
app.popups.MYPOPUP.properties.selectedKey = key;
app.popups.MYPOPUP.visible = true;
Now, go to the popup content and add the following on the onAttach event handler:
var key = widget.root.properties.selectedKey;
widget.datasource.selectKey(key);
This is the general idea of how to make it work; However, in order for it to work, your datsources in the widgets should be properly set up. Good luck!

Show alert if moving on without saving in Flex?

Functionnaly :
On one of my components of my application, I have an editing/lock system. When a user starts editing, he locks the file so other users cannot edit it.
Problem scenario : When the user activates "edition mode" and leaves screen, I would like to show a alert with two options : save changes, or discard changes.
There are different ways to exit screen :
There is a List on the left side containing other possible editabel data. A click changes the data in my component.
There is a menubar on top leading to other screens.
The edition component is embedded in a Tab navigator. When changing tabs, the alert has to show.
Closing browser.
Do I have to catch all of these events and plug at all those places?
Is there any kind of focusout mecanism?
The answer to the first question is: YES.
You need to watch all possible exit events that could harm the currently edited data.
Well, the problem is now how to manage this properly. Using an MVC framework you would trigger the appropriate commands from your components:
CHANGE_LIST_ITEM (new item)
CHANGE_TAB (new tab)
CHANGE_SCREEN (new screen)
Each command then checks if the currently edited tab has been saved or not. If not, it displays the Alert. Else, if there are no changes, it allows the list, the screen chooser and the tab bar to continue.
So your components (list, screens, tabs) need to implement some kind of rollback or preventDefault mechanism. Generally, changing their state must be allowed by a central validator (in MVC the command).
In the case of the list: I would suggest that the list is not selectable by mouse click but only programmatically. You set a listener on the list item click event. If the command allows setting of a new item it will notify the list. In MVC usually by sending an async message that gets received by the list's mediator. [[And even more correct: The command would set some model properties (e.g. currentListItem) and the model than sends an async message.]]
Edit: For the browser close event, you need to call a JavaScript expert.

Flex custom component first item not read by JAWS

Flex application is being made accessibility compliant. When a custom component is made visible based on some condition, the first item (either text or formitem or textarea) inside the component is skipped by Jaws. It reads from the second item. On pressing UP arrow, the first item is then read.
Is there a way to make the first item accessible without need for pressing UP arrow?
This is likely going to be related to focus management.
You're likely going to want to assign componentId.setFocus() to the first component in the current view when the view state changes.
You need to re-assess the focus when the state of your display changes. If you post how you are managing display state I can suggest exactly how to trigger that via an event or in your custom state method.
Also, if that doesn't work, try this once your screen is ready / state changed :
focusManager.moveFocus(mx.events.FocusRequestDirection.TOP);

click feature in Qt

I just want to clarify, weather the feature is present or not in Qt.
The scenario is like this,
I have a list view with items, I want to place the icon to the listview when the item is selected.
The selection I mean is, first time when I click item should be selected, next time if I click the same item then it should display some icon. Please note
It is not the double click. again if do select some other item same feature should continue
So is there any feature which handles this feature by default, any property or flag which I need to set to listview to behave like this or manual implementation
Is required for this.
No problem (: Now I understand what you mean... So if you click on an item it should be selected (for example highlighted in blue) and then when you click on this item again, an icon should be displayed.
I can't think of a regualar way to do this, there is no such flag or something.
The easiest way I can think of would be to store the index in a QList when you select it. And when you deselect it, you delete the index from the list. SO, when you click on an item you can check if it is in that list and if so you can display your icon.
Another way would be to create your own type of QModelIndex. Everytime, this index is selected, you set a bool like is_already_selected on true. When clicking on this item again you check this bool and then decide whether an icon should be displayed or not.
For further information, see: QListView, QAbstractItemView::currentIndex, QModelIndex

Is it possible to catch a comboBoxes value before change with a change event

I am displaying a combo box in something of a WYSIWYG preview. I want the user to be able to click on the combo box and see the options inside, but I don't want them to be able to change the value. I tried using preventDefault() on the change event but it doesn't work. I don't want to disable it because I do want the user to be able to "look inside" the dropdown.
So I'm trying to block the change, but can't. My next resort is to change the selected index back to what it was before the change, Is there any way to do this within the scope of a ListEvent.CHANGE event listener?
Current Workaround is to basically re-assign the controls selected item the same way I am defining the selected item when I originally build it (a default selection). So a user sees their change then it immediately changes back to the default selection.
Are you sure that a combobox is what you want? could you do the same thing with a list component that is not selectable?
update:
If you must use a combobox and you dont want the lag from listening for the event and resetting the control, I see two possible options. You could subclass the control and make your own. When you do, hijack any methods that set the value besides the initial selection.
Or, you could try something like this: http://wmcai.blog.163.com/blog/static/4802420088945053961/. The site seems like it is in another language but the code is still there. It will allow you to make your options disabled, so the user cannot choose one of the other options.
HTH

Resources