Under what conditions would a #State assignment not get set within the same code block?
I am battling a SwiftUI state issue and have found that in a block executed within a sheet closure, a view #State object is not retaining its value immediately after being set. If you look at the screenshot of the debugger break. The line directly above the green breakpoint sets the self.imageSource #State variable to selectedSelectedSource which is an enum. You can see in the watches that the value of selectedSource (First blue line) is ".library." Yet the value of self.imageSource (second blue line) is ".none"
I have tried multiple variations of this sheet code using all the patterns presentationMode, #binding the show variable, callbacks, asyncs and every time the #State imageSource never gets set. Ironically if I use an action sheet, it works without issue.
Please I am looking for answers pertaining to the mechanics of #State that would explain this behaviour.
Related
Scenario:
Application is tab-based; one tab is a container view having a 'Picker (Data) View'.
Picker View: the Picker is initially loaded with data via #State -> #Binder.
A 'Front Page' (Greetings) View is initially displayed over the Picker View within a ZStack{}.
User Acknowledges the front page which disappears to reveal the Picker View (#2).
Note: Data is received by the Picker per debug check.
The hidden Picker View shows the initial data.
Problem:
The revealed Picker View becomes empty; after dismissing the Front Page/View.
The following is a debug listing via BreakPoint of data:
Observation:
I want to access the data source ASAP to populate the Picker View to avoid having the user wait for the data. Hence the data is initially access prior to revealing the Picker View.
However,
the Picker View apparently gets re-rendered just prior to being displayed.
Note: I see the populated picker page if I comment-out the front-page code.
👉 I've added a boolean filter to avoid calling the Picker with an empty data payload.
Question:
How do I make the data more permanent; that is, stay until it is dismissed?
Do I have to make a concrete copy of a #Binding variable?
Non-SwiftUI fix:
Use a Singleton for the persistent data vector; and hence not influenced by the life of the controlling View:
final class DataSource {
static let shared = DataSource()
var myVar:String = "Hello World"
var countryNames: [String]?
}
This is so simple that it's elegant.
Still, I would like to use combine here, but the data life is too volatile.
I plan to review this paradigm further into my project as I become more proficient in Combine.
If anyone has a SwiftUI/Combine method of accessing, holding/sharing data that doesn't require a Singleton object, please post.
I’m struggling to obtain the new value that is being set in an editable Interactive Grid. I’ve created a dynamic action to be fired when the column has changed. The dynamic action is firing as expected, but it’s returning the previous value and not the value that triggered the event.
The dynamic action is set to execute JavaScript:
var $te = $(this.triggeringElement);
var rowID = $te.closest('tr').data('id');
var grid = apex.region('IG_SCALE_1').call('getViews','grid');
var model = grid.model;
var record = model.getRecord(rowID);
var column_val = model.getValue(record,”COLUMN_1”);
apex.item(“P1_HIDDEN_1”).setValue(column_val);
Let’s say column_1 had a value of 0 and that value was changed to 1. The code is setting the hidden item’s value to 0. I need it to be set to 1.
When I execute the following code I can see the old value in the array.
console.log(record);
Is there anything that I can do to obtain the new value?
Many thanks.. let me know if you have any questions!
You might be encountering one of the bugs, which are fixed in APEX version 19.2.
John Snyders described in his blog APEX IG Cookbook update for 19.2
One of the bugs had to do with changes to the last edited cell not always being saved.
A list of all fixed bugs in 19.2 is available here: APEX 19.2 Release Notes.
Search for 26963177 and 29132960 in particular.
Can you reproduce the issue in apex.oracle.com environment?
History, I am an experienced PL/SQL dev learning to use Apex and struggling with some of the concepts. Before working with PL/SQL I worked with various platforms including Delphi and VB.
Problem, how to pick up the value set in component from another component. The object of the exercise is to make the report in an interactive grid change dependant on a value selected in a drop down, the value in the drop down being in the where clause as a bind var. My original setup for this did not work. After various experiments with this I produced this test case where the object is for the label to display the value selected in the drop down:-
Page view
P300_SELECT (left) is a simple drop down, unmodified with the default values. P300_SELECTED_VALUE is a label set to display the value in P300_SELECT:-
Component setup
This does not work! And it continues not to work when I change the source setup of the label to be STATIC VALUE and set the value to &P300_SELECT.
I have also tried adding a CHANGE dynamic action on the drop down to call refresh on the label, it still does not work! In desperation to confirm that the value was indeed changing for the drop down I added a second true action to the change event executing the following javascript:
apex.message.alert($v("P300_SELECT"));
Sure enough, this works showing that the event is firing and that the value is correct:-
Label no change, but alert message works...
SO WHAT IS HAPPENING?
Why does the label not update even with a refresh called on it?
What do I have to do to make this work?
Thanks in advance for your help!
Bob
To do this
1 - Create one dynamic action to start when you change the value of P300_SELECT.
2 - Now there is a lot of ways to do this step, but I will sugest to do in this way. Create one true action in this dynamic action, this true action is "Execute PL/SQL code". The code is:
BEGIN
:P300_SELECTED_VALUE := :P300_SELECT;
END
In this true action put the item P300_SELECT in the field "Items to submit". And the item P300_SELECTED_VALUE in "Items to Return".
3 - Now create one more true action in this same dynamic action. This true action is "Refresh" and select the region of your report/IG.
***If the item P300_SELECTED_VALUE is just to test, so discard the first true action above and fill the field next of your select statement "Page items to submit" with the item P300_SELECT.
Why what you have try don't work?
1 - The source section is used to set the value when the page is loaded, this setup not affect changes after the page is loaded.
2 - The report is not refreshed because the item is not in the session after you change it.
Ex. https://apex.oracle.com/pls/apex/f?p=145797:15
Use this workspace to check something:
workspace: STACKQUESTIONS
user: test
password: test
app: 145797
page: 15
login on: https://apex.oracle.com/pls/apex/f?p=4550
I develop a game with cocos2d-x rc1 and I need a text field where I will show the score of the player. Which one to use cocos2d::Label or TextField defined in cocos/ui/UITextField.cpp ? What is the difference? For example, I have noticed that Label has enableShadow, but TextField misses.
Don't use a TextField for a mere output field. (Jeff Johnson: "GUI Bloopers", Blooper #17.)
Text fields are meant for input. The fact that they can be active or passive doesn't mean that they should be used in always-passive mode for output. To display a result, use a Label indicating what the following value is, and another Label for the value itself.
Score: 42
Later
One reason is that an inactive TextField typically has an appearance that dampens its visibility, like being grayed out. Another one is that the border surrounding a TextField identifies it as a place where data can be entered, if not now, then some other time; and this is bound to irritate users that are trained to observe such niceties - and there are, me 4 1 ;-)
I am working with a Google Motion Chart with has a play button and slider at the bottom that animates the chart. I would like to set the time unit/steps used by the slider. The default seems to be a day ("D").
My drawChart method sets the initial state and I tried setting the timeUnit to "M" - "duration":{"multiplier":1,"timeUnit":"M"} - for month but this did not change anything. I could not find any documentation on possible settings for the initial state variables.
Below is my method which sets the state:
function drawChart(data) {
var evalObj = eval("(" + data + ")");
var dataTbl = new google.visualization.DataTable(evalObj);
var motionchart = new google.visualization.MotionChart(document.getElementById('chart'));
var options = {};
options['state'] =
'{"iconKeySettings":[],"stateVersion":3,"time":"notime","xAxisOption":"_NOTHING","playDuration":15,
"iconType":"BUBBLE","sizeOption":"_UNISIZE","xZoomedDataMin":null,
"xZoomedIn":false, "duration":{"multiplier":1,"timeUnit":"M"},"yZoomedDataMin":null,"xLambda":1,"colorOption":"_UNIQUE_COLOR",
"nonSelectedAlpha":0.4,"dimensions":{"iconDimensions": []},"yZoomedIn":false,"yAxisOption":"_NOTHING","yLambda":1,"yZoomedDataMax":null,
"showTrails":false,"xZoomedDataMax":null};';
options['width'] = 800;
options['height'] = 400;
motionchart.draw(dataTbl, options);
}
Is "M" the setting for month? How do I change the slider to use months instead of days for its steps?
The documentation says:
The second column must contain time values. Time can be expressed in any of the following formats:
Year - Column type: 'number'. Example: 2008.
Month, day and year - Column type: 'date'; values should be javascript Date instances.
Week number- Column type: 'string'; values should use the pattern YYYYWww, which conforms to ISO 8601. Example: '2008W03'.
Quarter - Column type: 'string'; the values should have the pattern YYYYQq, which conforms to ISO 8601. Example: '2008Q3'.
Reading another thread, it looks like Google is throwing this in the trash and are not going to be enhancing the time units.
Try this.
You can specify that the motion chart start with a specific state: that is, a set of selected entities and view customizations. To do this, you'll need to first create and display the chart, then make any state changes that you want the chart to show (select values, change settings, etc), then export these settings as a string, and finally use this string in your code, assigning it to the "state" option. The next two sections describe how to export and then use the state code.
Open a working chart and set the settings that you'd like to capture. Settings you can specify include opacity levels, zooming, and log vs linear scaling.
Open the Settings panel by clicking the wrench symbol in the lower right corner of the chart.
Click the Advanced link in the lower left corner to add the Advanced panel to the set.
Expand the Advanced panel and copy the contents of the State text box to your clipboard. (Note: instead of using the menu, described in steps 2—4, you could insert a button on your page that calls getState() and displays the current state in a message box.)
Assign the state string that you copied in the previous step to the "state" options parameter in your code, as shown here. When passed into the draw() method, the chart will be initialized to the state specified on startup.