Picture this sparsely populated NSMatrix, five coloured columns (0-4), with the most recently added column in orange. These are populated with stand-in objects (random numbers) with the (x,y) coordinates noted. "Blank" cells have stand-in NULL objects. This is kinda working.
I have four data "sources" (A-D) at the top that I want draggable onto the matrix. They are tagged with numbers that represent target rows (0-3). I can't get these to drag even though I think I've done NSDragSource correctly.
Example behaviours:
If I drag cell B (with 0,2) onto the "centre" area of the column (4,y), its contents will merge with the two empty cells (rows 0 and 2). If I drag onto the left or right area of the column, I will get a prepended or appended column -- in this case, a sparse one.
If I drag cell A (with 0,1,2,3) onto any cell, it will create a new column.
If I drag cell D onto column (0,y) or (4,y) it will merge; dragging it anywhere else will create new sparse column. Doing so with C anywhere will create a new sparse column.
As one could surmise, this complex merging behaviour has led me here rather than, say, to NSTableView.
I don't so much have a problem of identifying the left/center/right areas or merging the data or creating new columns -- I need help creating the proper NSPasteboard interactions and/or the NSDragging setup: (I ultimately want to using a custom NSManagedObject in Core Data that will be identify which rows are populated, but I'm starting here).
I'm trying to prototype a NSStringPboardType attached to the four NSTextFields that will be draggable. No dice.
I can make my NSMatrix receive strings (or an NSFilenamesPboardType) from the pasteboard. No problem there.
Once I receive the appropriate incoming cell (string), I can riffle through it and figure out whether to merge with the current column, or create a new column -- again, that's not the issue.
Things I have done...
1) Subclassed the NSTextField...
#interface CellStringView : NSTextField <NSDraggingSource>
2) Registered the text fields' dragged types & attempted a drag session...
- (void)awakeFromNib {
[self registerForDraggedTypes:#[NSStringPboardType]];
}
- (NSDragOperation)draggingSession:(NSDraggingSession *)session
sourceOperationMaskForDraggingContext:(NSDraggingContext)context {
if (context == NSDraggingContextWithinApplication) {
return NSDragOperationCopy;
}
else
return NSDragOperationNone;
}
-(void)dealloc {
[self unregisterDraggedTypes];
}
My draggingSession:sourceOperationMaskForDraggingContext: method is never even called.
I'm new to this NSPasteboard stuff, so any help would be appreciated.
Related
I want to create a pdf document using the TPPDF package in swift.
Is it possible to add in a specific cell multiple items?
I want to add a checkmark as image / Symbol and a related text behind it.
(No accessable element just indicator)
Column A
Column B.
'text'
image + 'text'
'text'
image + 'text'
I needed to split related information's in two rows which get split by the page break.
is it possible to avoid this?
e.g. ObjectA is indicated in 2 rows [row 1 & 2] with some vertical and horizontal merges.
when it comes to a page break, the vertical merges sometimes are divided by the page break.
[Sample Table Image Page break]
[Sample Table Image one object needs 2 rows]
I am new here. Any advice to improve this question to get better support appreciated.
The documents and APIs I noticed did not support anything like this.
I'm currently working on creating a new stencil for several components I use in Visio and I'm stuck at the point of providing proper labels. If you use a resistor from Visio stencil it automatically generates a label "R1" (for first resistor) and "Rk" for the kth resistor. How can I do something similar for my own stencil ?
1- I need to generate a label "ABCD #" (# number automatically generated based on instance count)
2- How can I position the location of this field?
PS:
1- Visio components have a custom defined field which allows for this (which I don't know how to create)
2- For capacitor for example the shapesheet shows an interesting entry
=SETF(GetRef(User.Label),"""C""&"&ThePage!User.AccumulatorCount)&SETF(GetRef(ThePage!User.AccumulatorCount),ThePage!User.AccumulatorCount+1)
which supposedly is how the count and name are generated (I'm not sure how the AccumulatorCount is defined it differs from element to element).
Thank You!
The EventDrop ShapeSheet cells for various electrical shapes have formulas similar to the one you have discovered:
SETF(GetRef(User.Label),"""C""&"&ThePage!User.AccumulatorCount)&SETF(GetRef(ThePage!User.AccumulatorCount),ThePage!User.AccumulatorCount+1)
The ShapeSheet for the page has a cell: User.AccumulatorCount for capacitors. Other User cells will be added as other shapes are dropped. You can set up your own system by adding a User cell to the page, say: User.Widget. Then you place the "Widget" version of the "SETF" formula into your own shapes.
You can create user cells by:
Open the ShapeSheet for the Page (right-click blank area of page, Show ShapeSheet)
Right-click in ShapeSheet and choose Add Section
Add a User-defined cells section
Find the User-defined cells section and similarly add rows to it via
right-clicking
You change the row names by typing over the red, row-name text on the left.
You enter values and formulas in the cells as you would in Excel.
You can toggle viewing formulas vs. viewing values by pressing F5
while in the ShapeSheet.
You have to make the User cell in the page first, so that your shape can reference it. Once your shape references the page cell, you can drag your shape into a stencil, and it will "drag the page User cell along too". So now, you can drop your Widget shape into a new document, and it will create the page User cell on the fly.
The system is basic and fragile. The count only goes up, and never down. If you have shapes with 1, 2, 3, 4 and you delete 1 and 2, the next shape will still be 5.
Recently I had a bad headache (and I'm still struggling) to find out how to retrieve all values inside an UIPickerWheel. For me should be enough to move at particular row of the wheel, but I can't! So frustrating! I tried to scroll row by row to retrieve all values (https://stackoverflow.com/a/39300344/821407) but it's so slow! Any clue?
NB: I can't use adjustToPickerWheelValue because my root problem is that I don't know the value since they are dynamic and I would like to avoid launchArguments/launchEnvironment.
This is probably not the answer you were hoping for but it is not possible to get the title of all rows in a UIPickerView in a UITest.
As you know when running a UITest you can only access your app's UI elements via the XCUIElement class. That class has a value property that gives you some information about the UI element you access. When accessing a UIPickerView the value gives you the title of the currently selected row. But only of the selected row. You can access the picker's row elements, but unfortunately the value property for the row elements is always empty. So, no luck here. All you the info you can get is the number of rows of your picker.
This is not really surprising though. Even if you had access to the UIPickerView, you could not access the titles of all rows directly. UIPickerView does not know about the titles that it displays. It is the job of the UIPickerViewDataSource to provide the titles.
So, unfortunately, if you need to know all the row titles of your UIPickerView in a UITest, you really have to select each value one by one via your app's user interface.
But it does not have to be as complicated as in the answer you linked. Instead of simulating a scroll you can simply tap on the next row to select it (should be slightly faster):
let pickerView = app.pickerWheels.element
let numRows = pickerView.children(matching: .any).count
var values: [String] = [pickerView.value as! String]
for _ in 0..<numRows {
pickerView.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.55)).tap()
values.append(pickerView.value as! String)
}
In your question you do not really describe what you are trying to test. But if you want to test if the picker has the correct row titles maybe a UnitTest would be a more practical approach?
When creating a UITableViewController there are two situations that create an "ugly" UX
calling/open it without any data in it --> shows an empty table (i.e. empty rows,UITableViewCell, as many as fit in the window)
calling/open it with fewer rows of content that fit the window --> show the full rows followed by empty rows
I wish to receive the following result:
if there is no data show a picture or view with text - there isn't any data yet or something like that
show only the full lines and no more rows (blank or background image)
Is there a way to achieve that?
To add these effects, you will probably have to make your own UITableViewController from a regular UIViewController, and even subclass UITableView. If you have a regular UIViewController with your filler image/text as the background, you can place a UITableView on top and hook up the delegate/datasource. Now, in your code, detect when there is no data available and set the hidden property of the UITableView accordingly.
As for the following empty rows, you will either have to turn off the row separators (in IB), or subclass a UITableView (can't help you there). Good luck!
I have a UITableView with some empty sections. I'd like the user to be able to move a row into them using the standard edit mode controls. The only way I can do it so far is to have a dummy row in my "empty" sections and try to hide it by using tableView:heightForRowAtIndexPath: to give the dummy row a height of zero. This seems to leave it as a 1-pixel row. I can probably hide this by making a special type of cell that's just filled with [UIColor groupTableViewBackgroundColor], but is there a better way?
This is all in the grouped mode of UITableView.
UPDATE: Looks like moving rows into empty sections is possible without any tricks, but the "sensitivity" is bad enough that you DO need tricks in order to make it usable for general users (who won't be patient enough to slowly hover the row around the empty section until things click).
I found that in iOS 4.3, the dummy row needs to have a height of at least 1 pixel in order to give the desired effect of allowing a row to be moved into that section.
I also found that the dummy row is only needed in the first and last section; any sections in between don't have this problem.
And it looks like in iOS 5.0, no dummy rows or special tricks are needed at all.
While managing the edit, you can monitor if the table view is in Edit Mode. Use that flag inside of cellForRowAtIndexPath to decide weather or not to display the 'blank' row. While in 'regular' mode, the row will not display, but when the user taps 'edit' cellForRowAtIndexPath should get called again and this time decide to display the row. The details of how to do that depend on your data source and how you are gluing it to the display. If you aren't getting the call again, you can manually inject rows with insertRowsAtIndexPaths / deleteRowsAtIndexPaths and/or call reloadData to force a refresh.
I found that if you return -1.0 from the heightForRowAtIndexPath method it will remove the 1 pixel line.