I would like to set up a view controller with a 2-component picker where each side contains the same 7 objects. Each object carries the same value for both components. The user would make a selection from each side, enter a value in a provided text field (and optionally tap a "Calculate" button). A calculation would occur using that value and the values from the two picker component objects that were selected and the results would be displayed in a label.
For example, each picker contains the letters a - g. Each letter carries the value of 1 - 7 respectively, for each side of the picker. The user selects "b" and "d" and enters 10. The calculated result of 10 * 2 / 4 = 5 is displayed.
It sounds simple enough. I've found tutorials for doing calculations using values associated with a 1-component picker as well as working with 2-component pickers, but nothing for doing calculations with 2-component pickers. My experience with Xcode is somewhat short. So, feel free to go into detail.
Related
I'm automating tests for a desktop application on Windows platform. I'm using HP UFT and VBScript.
In a WinListView control which is used to display a multi-valued list(Each row in the list has four columns in it). After hovering on each row to select it, when mouse click operation is performed on any of the four cells the respective control in that cell shows up(an editbox or a dropdown list)
It seems that the developers have embedded temporary WinEdit and WinComboBox controls in the cells of each row which makes it difficult to use Object spy on them. I succeeded in getting object spy to work on those by holding control key, but the properties of those objects are not unique, for instance ComboBox in the third cell in different rows has the same properties.Posting ObjectSpy results here.
**ComboBox in Row 1 Cell 3**
"Class Name:=WinComboBox",
"abs_x:=1041",
"abs_y:=551",
"all items:=Hours\nMinutes",
"attached text:=",
"enabled:=True",
"focused:=True",
"height:=21",
"hwnd:=7602202",
"items count:=2",
"nativeclass:=ComboBox",
"object class:=ComboBox",
"regexpwndclass:=ComboBox",
"regexpwndtitle:=Minutes",
"rightaligned:=False",
"righttoleftlayout:=False",
"righttoleftreading:=False",
"selection:=Minutes",
"text:=Minutes",
"visible:=True",
"width:=90",
"window id:=7988488",
"windowextendedstyle:=0",
"windowstyle:=1342177987",
"x:=354",
"y:=257"
**ComboBox in Row 5 cell 3**
"Class Name:=WinComboBox",
"abs_x:=1041",
"abs_y:=619",
"all items:=Hours\nMinutes",
"attached text:=",
"enabled:=True",
"focused:=True",
"height:=21",
"hwnd:=11601852",
"items count:=2",
"nativeclass:=ComboBox",
"object class:=ComboBox",
"regexpwndclass:=ComboBox",
"regexpwndtitle:=Minutes",
"rightaligned:=False",
"righttoleftlayout:=False",
"righttoleftreading:=False",
"selection:=Minutes",
"text:=Minutes",
"visible:=True",
"width:=90",
"window id:=7988488",
"windowextendedstyle:=0",
"windowstyle:=1342177987",
"x:=354",
"y:=325"
I have tried selecting rows using WinListView.GetItem but that gives hold of the first cell only which is an editbox and it works. For the remaining three columns I can't find any workaround.
I have tried performing clicks using WinListView.GetItem().Select operation providing offset in pixels to click on each cell but that doesn't activates the embedded controls although I see the mouse moving and performing clicks when the test runs.
Record and play didn't provide much insight either as the play operation doesn't replicate the actions successfully every time and uses same and generic names for actions on cells of different rows.
WinListView("WinListView Name").WinEdit("Edit").Set "20"
DialogObject.WinComboBox("ComboBox").Select "Hours"
Image 1 The basic WinListView looks like this
Image 2 After selecting a row and clicking on a cell the ComboBox or EditBox appears
I am making an app, uses UIDatePicker component. Everything works fine with the below code.
myDatePicker.datePickerMode = UIDatePickerMode.Date
My problem is here how to avoid the year column, days and months are the only data that i want to show in the component.
Like:
2 November
3 November
thanks
This is a bit tricky but if you don't have to deal with date formats and locale it may work for you.
Place the UIDatePicker inside a UIView and align all sides to the containing view's edges. Then change the right side constraint from 0 to -100 (you may have to find a different number depending on the size you want to give it).
In the containing UIView's User Defined Runtime Attributes add a key named clipsToBounds, make it a Boolean and make sure it is checked.
This will hide the edge of the Date Picker that is aligned beyond the UIView's right side.
Make sure you set a minimum and maximum date for January 1st to December 31st of a specific year (so the user doesn't accidentally go outside that year and you don't have to deal with multiple years).
I’m working on a little optical-illusion app. As part of that, I have a model key (a CGFloat) representing an angle.
I have three controls — an NSTextField, an NSStepper, and an NSSlider — each bound to that model key. (The NSTextField was created as a “Text Field with Number Formatter”.)
I want that angle to fall between -45 and 45 degrees at all times. I also want it rounded to the nearest integer.
To that end, I’ve implemented a setAngle method that applies those rules. In addition to rounding its input, it replaces any value falling outside the acceptable range with the closest valid value.
I notice that whenever I use one of the controls to change the angle’s value, the other two controls reflect the post-processing value — but the submitter itself does not.
For instance, if I move the slider, the text field shows the rounded value, not the possibly-fractional value that the slider submitted.
Likewise, if I enter 44.5 in the text field, the slider’s position corresponds to 45.
However, the submitting control still displays the “raw” value it submitted: the text field in the last example continues to read 44.5.
Placing
[self willChangeValueForKey:#"angle"];
and
[self didChangeValueForKey:#"angle"];
around the code in setAngle that actually changes the value had no effect on this.
My principal questions, then, are these:
Is there, generally speaking, a “correct” way to alter a value submitted by a control, such that all controls bound to the key get the updated value? I'm not entirely sure that angleSet is the right place to pull the sort of post-processing shenanigans I am, but I'm even less sure where else I should do so. (The Apple docs regarding validation in key-value coding expressly discourage using validation to this end.)
If there's no general-purpose mechanism for setting a tweaked version of model key, and notifying all associated controls after the fact, is there a way to identify the single control doing the actual setting, and update it with the post-processed value?
Thanks in advance!
use cocoa binding is the most easiest way for this situation.
declare a property
#property CGFloat angle;
and bind it to value of the controls with keypath angle or someobject.angle (it depends on your implementation)
I’ve come across a problem with Windows list controls (I am specifically using MFC, but it looks like it applies to all list controls in the Windows common controls library).
In my specific case, I want to create a list control that has two or more columns. The first column (0) is text-only and is used to allow the user to jump to entries by typing the text in that row. Column two (or three, or four, or whatever) has an image (or an image and text; either way).
This much is all well and good and can be done easily without problem, however the final list control then ends up having a space to the left of the text in column 0 (it may be on the right on an RTL system). This spacer appears to be reserved for an image and I cannot figure out a way to prevent it. (Arranging the specific order of the columns did not change anything.)
Looking around, I found some other people complaining of the same thing, specifically this thread which leads to this thread. The proposed solution does not work because as was stated, simply shrinking the width of column zero merely cuts off the text rather than the image spacer (plus, you then have to prevent and/or process any changes to column widths that the user tries to make).
Does anyone have any ideas of how to fix this bug short of writing a list control from scratch or using one of the too-fancy grid controls on CodeProject/CodeGuru/etc.?
Thanks a lot.
Did you try to change the iIndent member of the LVITEM struct? MSDN says this:
iIndent Version 4.70. Number of image widths to indent the item. A
single indentation equals the width of
an item image. Therefore, the value 1
indents the item by the width of one
image, the value 2 indents by two
images, and so on. Note that this
field is supported only for items.
Attempting to set subitem indentation
will cause the calling function to
fail.
Column 0 is special in a ListView. As soon as you assign a small image list to the ListView, the control expects you to show an image in column 0, so it leaves space for it.
Solutions:
make column 0 zero-width, give it the value you want the user to be able to type. Column 1 becomes your "first" text column. Columns 2+ are for your images. You need full row select style for this to work. Yes, you have to prevent the user from resizing column 0. Yes, that is a pain.
make a column that does have an image to be column 0 and use LVM_SETCOLUMNORDERARRAY to rearrange the display order
owner draw the items.
give column 0 an icon (just to cover all bases)
I have a dynamically created tabpage for windows forms. the tabpage is split into two horizontal panels. The top panel should be able to hold up to 4 textboxes like this
TextBox1
TextBox2
TextBox3
TextBox4
There WILL be atleast one TextBox. Maximum is 4. How do I create a TabPage with two panels where the top panel only takes up the real estate as needed(i.e only use up the real estate for one textbox or 2 textboxes, or 3 textboxes or the maximum 4 textboxes) and the rest of the tabpage is available for Panel2.
Adjust the TabPage.height for the count of TextBox instances. Adjust the lower TabPage.height to fill in the remaining space.
Have you looked at FlowLayoutPanel? You can make any control (which a textbox is if i remember correctly) in the panel to break, that is, make the next control appear on a "new line". This property appears in the Property Window when selecting a control inside the panel, I just don't remember the name.