My App Basically has a start screen where the user enters how many exercise reps they want to do. I use this as my max variable, and then I have a button which activates a counter mechanism which adds up to max value. When it equals max value, the UI resets and I am meant to get back to Screen 1.
I have been working this problem for over an hour and I can't figure out why my button doesn't reappear when the clicker value = user input(max value).
I have coded it to do so in
ButtonScreen1.hidden = false
UserInputScreen1.hidden = false
LabelScreen1.hidden = false
But the Button won't reappear. But it appears at the start, so it's not a view controller issue to my knowledge.
Images (Top One Is Without Button which Should be Present at the End of the Application) (Bottom One is What It Looks like as it Starts which I am trying to replicate at the End)
For Full Code
Related
let firstWin = new BrowserWindow()
let secondWin = new BrowserWindow()
secondWin.hide()
Let's assume there are three active windows. Two of them belong to my application (firstWin and secondWin). The third one is Chrome (or any other application). firstWin is at the bottom of the hierarchy, Chrome in the middle and secondWin on top.
secondWin
Chrome
firstWin
When I call secondWin.hide(), firstWin automatically pops up and gets focused. The result is then:
firstWin
Chrome
Is there any way to prevent that? I would like firstWin to not pop up but stay at the bottom of the window hierarchy when I hide secondWin.
I believe you should be able to listen to a window's focus and/or show events (see https://www.electronjs.org/docs/api/browser-window)
You could then make "a decision" to immediately call hide() on that window. (I suppose there is a chance of it flashing on screen briefly.)
(How to make that decision is a bit tricky; I suppose you could record the time you called secondWin.hide() and use the number of seconds since then to decide... not ideal!)
As another approach, just before calling secondWin.hide() you could look at the current state of firstWin, and if that is minimized or hidden, you could instead call app.hide() (see https://www.electronjs.org/docs/api/app#apphide-macos).
(Unless you always want all windows hidden when one window is hidden, this isn't going to scale very nicely beyond 2 windows, unfortunately.)
The solution that I went with for now is to set the opacity of the window to zero and deactivate mouse events. That would be
secondWin.setOpacity(0);
secondWin.setIgnoreMouseEvents(true);
instead of
secondWin.hide()
You then reverse the settings whenever you want the window to become visible again. It's a bit hacky but works for now. Let's see if anyone finds a better solution. Ideally there would be an event like window-about-to-be-shown, which you can plug into and call event.preventDefault() on.
It's been a while since the last answer but here is how I solved this issue:
setting
firstWin.setFocusable(false)
just before calling
secondWin.hide()
will prevent the first window from getting focused.
After that, you can restore the focusable state again calling
firstWin.setFocusable(true)
I'm using iCarousel in my Swift+Sprite Kit game, where the user has unlocked and locked items.
The locked items would display some info like current user coins, and some text that says "UNLOCK THIS FOR: X amount of coins", if the carousel item isn't locked, it won't display any of that information, just a button that says "Select".
Now, I got that working, but it will only work when i start swiping the items and not the first time the carousel shows up.
To make that work, I do it inside carouselCurrentItemIndexDidChange() method. And that obviously changes when I swipe.
How can I set the current carousel index at start so then I can force to show or not show the information depending if the item is locked or unlocked and not only when I start swiping?
To add more information about this, imagine that the user selected the item at index 4, i save that index locally. So if the user closes and opens the game, the carousel should begin at 4 not 0.
Thanks in advance.
You should set up your carousel views in viewForItemAtIndex: reusingView:. The view returned by this method should represent the current state of that carousel item; so locked or "Select" as appropriate.
If the state of an item changes then you can call reloadItemAtIndex: to have iCarousel request an updated view for that item by calling viewForItemAtIndex: reusingView:.
You can scroll the carousel to a particular item by calling scrollToItemAtIndex:animated:
I am trying to make an image picker component in LibreOffice.
I have a dialog that is dynamically filled with images. When the user clicks on one images, it should be selected and the dialog should be closed.
The problem is that the number of images is variable. So I need to enable scrolling in the dialog (so that the user can navigate through all images).
There seems to be some properties on the dialog object (Scrollbars, Scroll width, Scroll height, etc)
However, I cannot find a way to use them anywhere.
Any ideas?
The scrollbar is one of the Controls available through the dialog box editor. That is the easier way to put a ScrollBar on a dialog box. Just insert it like any other control. There is a harder way via DialogModel.addControl but that seems non-essential to answering this question.
If you add a scrollbar to the dialog box and run the dialog box, you will find it does nothing by default. The functionality (apparently) must be written into a macro. The appropriate triggering event is the While Adjusting event on the ScrollBar object, although it does not trigger the macro simply with the "Test Mode" function in the dialog editor. Running the dialog box through a macro triggers the While Adjusting event when the scroll arrows are triggered, when the slider area is clicked to move the slider, and when the slider itself is dragged. The Object variable returned by the scrollbar event contains a property .Value which is an absolute value between 0 and the EventObject.Model.ScrollValueMax, which allows you to manipulate the other objects on the page manually based on the position of the slider.
Yes, that's right, manipulate objects manually. The sole example I found, from the LibreOffice 4.5 SDK, does precisely this. Of course, it is not as bad as it sounds, because one can iterate through all of the objects on the page by reading the array Dialog.getControls(). In any event, the secret sauce of the example provided in the SDK is to define Static variables to save the initial positions of all of the objects you manipulate with the scrollbar and then simply index those initial positions based on a ratio derived from the scrollbar Value divided by the ScrollValueMax.
Here is a very simple working example of how to scroll. This requires a saved Dialog1 in the Standard library of your document, which contains an object ScrollBar1 (a vertical scrollbar) and Label1 anywhere in the dialog. The ScrollBar1 must be configured to execute the macro ScrBar subroutine (below) on the While Adjusting event. Open the dialog by executing the OpenDialog macro and the scrollbar will move the Label1 control up and down in proportion to the page.
Sub OpenDialog
DialogLibraries.LoadLibrary("Standard")
oVariable = DialogLibraries.Standard.Dialog1
oDialog1 = CreateUnoDialog( oVariable )
oDialog1.Execute()
End Sub
Sub ScrBar (oEventObj As Object)
Static bInit As Boolean
Static PositionLbl1Y0 As Long
oSrc = oEventObj.Source
oSrcModel = oSrc.Model
scrollRatio = oEventObj.Value / oSrcModel.ScrollValueMax
oContx = oSrc.Context
oContxModl = oContx.Model
oLbl1 = oContx.getControl("Label1")
oLbl1Model = oLbl1.Model
REM on initialization remember the position of the label
If bInit = False Then
bInit = True
PositionLbl1Y0 = oLbl1Model.PositionY
End If
oLbl1Model.PositionY = PositionLbl1Y0 - (scrollRatio * oContx.Size.Height)
End Sub
The example provided by the SDK does not run on my setup, but the principles are sound.
There appears to be a second improvised method closer to the functionality one might expect. This method uses the DialogModel.scrollTop property. The property appears to iterate the entire box up or down as a scroll based on the user input. There are two problems using this methodology, however. First, unless you put the scrollbar somewhere else, the scroll bar will scroll away along with the rest of the page. You will need to adjust the location of the scrollbar precisely to compensate for/negate the scrolling of the entire page. In the example below I tried but did not perfect this. Second, the property seems to miss inputs with frequency and easily goes out of alignment/ enters a maladjusted state. Perhaps you can overcome these limitations. Here is the example, relying on the same setup described above.
Sub ScrBar (oEventObj As Object)
Static scrollPos
oSrc = oEventObj.Source
oSrcModel = oSrc.Model
scrollRatio = oEventObj.Value / oSrcModel.ScrollValueMax
If IsEmpty(scrollPos) = False Then
scrollDiff = oEventObj.Value - scrollPos
Else
scrollDiff = oEventObj.Value
End If
scrollPos = oEventObj.Value
oContx = oSrc.Context
oContxModl = oContx.Model
oContxModl.scrollTop = scrollDiff * -1
oSrcModel.PositionY=(scrollRatio * oContx.Size.Height/5) * -1
End Sub
This (sort of) will scroll the contents of the entire dialog box, within limits and with the caveats noted above.
I have a program with multiple tabs, so when I go to a new tab I want to somehow temporarily get rid of all of the elements on the other tabs until the user returns to that certain tab. I am having trouble doing this with textFields, once I hide them I cannot get them to reappear. So far I have tried removeSelf, delete, and isVisible and all of them have had the same problem. Is there another way to temporarily hide a textField and bring it back later on?
edit: this is in Lua using the Corona SDK
You can normally do it with isVisible or with the .alpha property :)
Set .alpha = 0 when you change tab, and .alpha = 1 when you come back to the tab.
I have a flash file where the first frame contains two buttons, one of which takes the user to the second frame, and the other takes them to the third frame. At each of those frames, various text fields and variables can be manipulated via SimpleButtons. Both Frame 2 and Frame 3 have "back" buttons to take them back to Frame 1.
Currently when the user navigates back to Frame 1 for the second time (thus playing it for a third time), my second button appears to no longer exist, and I receive an error. Both buttons on Frame 1 were placed via the Flash IDE. Why is my button popping out of existence, when it did perfectly fine the previous two times? Below is my code for Frame 1. The "back" buttons simple remove event listeners and then call gotoAndStop(1)
var inited:Boolean;
var cache:SharedObject;
var libsans:Font = new libsansreg();
this.addEventListener(Event.ENTER_FRAME, frameEnter);
stats.addEventListener(MouseEvent.CLICK, statsclicked);
modules.addEventListener(MouseEvent.CLICK, modsclicked);
function initcache():void
{
this.cache = SharedObject.getLocal("RPG_Shooter")
}
function frameEnter(e:Event):void
{
if (!inited)
{
inited = true
initcache()
this.gotoAndStop(1)
}
}
function statsclicked(e:MouseEvent):void
{
this.removeEventListener(Event.ENTER_FRAME, frameEnter)
stats.removeEventListener(MouseEvent.CLICK, statsclicked)
modules.removeEventListener(MouseEvent.CLICK, modsclicked)
this.gotoAndStop(2)
}
function modsclicked(e:MouseEvent):void
{
this.removeEventListener(Event.ENTER_FRAME, frameEnter)
stats.removeEventListener(MouseEvent.CLICK, statsclicked)
modules.removeEventListener(MouseEvent.CLICK, modsclicked)
this.gotoAndStop(3)
}
I actually had similar problem at one point. It has to do with garbage collection which is not the best in Flash to begin with, but the IDE's compiler settings make it so much more insane. There are a couple of tricks you can try which might help.
Make sure you remove all listeners before leaving the frame.
Go to a "blank" frame (something which still has a background and styling, but no interact-able components) for even a 5/1000 of a second
Set the variable names to "null" on frame one (so if your component on frame 3 is named "foo" put foo = null on frame one)
put var foo:MovieClip on frame 1. repeat for all MovieClips which you might be using that are named ahead of time.