2016년 11월 20일 일요일

Two major problems: Change buttons text with button clicks


See text in attached file.
blocks (2).png 표시 중
-- 
I do not see anywhere where you are testing to make the textfields visible or not. Maybe I do not understand well enough what you want to do, it should be possible, but probably you are missing the right if-s.
So, what really happens and why is it not OK?
Cheers, Ghica.

-- 
That's because I had no clue on how to do it correctly. I give it a shot here (see attached file)

The outcome of this is: All buttons become visible. That's not what I want, I want only the first one to become visible, but no clue on how.
Skärmbild_2016-11-20_15-06-56.png
-- 
you need additionally an index variable, which increments inside the for each loop to get 1, 2 or 3 inside the loop
it might help to take a look again at these examples
Thank you. I will read them thouroughly and try to do it... Advanced features are hard :(

-- 
Ok.. so what I need is:

When ADD.longclick
set global split to split text: Textbox1.text at ,           <------- this is where the textlist is created.
for each component in list: get global buttons
set Button.text of component: get component
to: select list item, list: get global split
index: get index of global buttons corresponding to global split

I need a way to do the bold stuff. I can't find a index = component... See attachments aswell.

any suggestions?
Namnlös.png 표시 중
Skärmbild_2016-11-20_18-06-46.png 표시 중


-- 
Look agan at Taifun's reply. You set a global index to 0, outside the loop and within the loop you add 1 to it and use its value as the index to the list of buttons.
Cheers, Ghica


--
Yeah, I've tried that, cant get it to work... Guess I've hit my roof.

--
Look agan at Taifun's reply. You set a global index to 0, outside the loop and within the loop you add 1 to it and use its value as the index to the list of buttons.



what about providing an updated scxreenshot after trying what we suggested?
Taifun

-- 
Will do, but I've shut the pc off. I'll be back tomorrow.

Im tremendously thankful for all the help.


--

Ok, so I made two different projects for my two problems. I've uploaded screenshots and aiafiles to both. Please note they are two different problems.

1. ONEBYONE
I want the text in the text box to be added to the next text box which is visible.false. I have no clue... Am I even on the right track? Right now alla buttons get visible and get the text.

2. LIST
I want the list entered in the text box to be the text of the buttons, so index 1 of textbox list = text to button 1, index 2 of textbox list = text to button 2, etc, for the length of the list, but maximum the number of items in the button list. I've added the problem notification of this too.
BLOCKSLIST.png 표시 중

BLOCKS - ONEBYONE.png 표시 중
LISTproblem.png 표시 중

TexttobuttonLIST.aia

TexttobuttonONEBYONE.aia

-- 
WOW, I FIGURED OUT ONEBYONE! HOORAY! Now it's only LIST left. HOORAY, so happy right now!

-- 
 Snap17.png
Congratulations!
Here is the solution to the list problem.
One point to note: if you would enter 1,,2 the text for the button b would be an empty string, I think that is better than invisible, but of course you could have your if statement back and make B invisible in that case..
Cheers, Ghica.


-- 
thank you thank you thank you thank you! I had almost all the right components, just at the wrong places.

-- 
Ok, so now that I know how to do this, I've been working on how to make the buttons visible to be the next batch of buttons. Example:

APP.click (first time) - list is 3 indexes long

Button 1-3 become visible

APP.click (second time) - list is 4 indexes long

Button 4-7 become visible and gets the text, not 1-4. 1-3 stays what it was before.

I've tried to do this, see attached file. Why doesn't it work? 
blocks (2).png 표시 중
-- 
Because:
You are iterating over the button list twice, once via the component number and once using a for each. Take out the for each, and address the button in the list via an index.
You will need two indexes now. One that keeps the position in the button list, and one that you reset each time when ADD is clicked, for the split list.
(by the way, settin gobal index to get index is rather useless, you set the value of the global to the value it already has).
I am sure you can figure this out now!
Cheers, Ghica.

-- 
Haha, don't be so sure. English is not my first language, and this is the first time ever I've been programming, so I'm figuring it out as I go, and I love it.

"address the button in the list via an index" - what does that mean? which block?

Should I remove both For each?

"One that keeps the position in the button list" - how do I?

I do thank you though, for using your precious time on me :) I am lost, but learning so much.


-- 
I have somewhat of a feeling that this would work to?
Namnlös.png 표시 중
-- 

Snap19.png.
If you would make the list in a proper way, maybe. Now you are making a list of one element??
But look at the attached blocks. I think they should work, but I have no time to try right now.
Cheers, Ghica.

-- 
Thank you! Your blocks didn't work right away, but it gave me a push in the right direction. Now it does exactly what I want, but I get two error messages (see attached files). The first is every time I add a list and the second is when the length of the buttonindex exceeds the length of the button list. Maybe there is a way to get rid of them, I gave it a try with the logic and block you see to the right.


1.png 표시 중


2.png 표시 중

3.png 표시 중
-- 
This is because you are trying to read past the end of the list, as the error message says. In my blocks, that was not possible, so why it did not work?
You should set the button component within the if, (after you have tested that the index is within bounds)
Cheers, Ghica.


--
Hmm, I really don't know why yours didn't work, I double checked the blocks, but it didn't give the wanted result :S

Ok, I set the button component within the if, it stopped the error message number 2, with the big list. Error message number 1 still shows. And the button index keeps increasing, this is not good, if I wanna add another list.


--
 Snap20.png
Shame on my face. There were indeed some problems. 
I did not increase the splitindex, I should have used number to use as button index, and save the buttonindex only when the button will be visible.
It works now, I tested it.
I made some changes and therefore I add the .aia: I made the screen scrollable, so  you can see the last buttons. And I made a reset button, so you can start over without restarting the app.
Cheers, Ghica.

--  
Thank you :) This is fantastic. 

Ooooooone last problem with this. IF:



This is only a small part of a bigger app I'm building. When it's done I could send you a copy so you'll see what I needed it for :)

-- 
 Snap22.png
There is indeed a slight problem here if you want to be able to reuse the list.
The button index is increased at the beginning of the ADD.Click event, because you want the text to be placed in the next button.
But you do not want to do that when the button index already has its maximum value, i.e. buttonindex >= lenth of list buttonlist.

Now for your second question. This is more difficult than you think!
First you must make clear for yourself what you really want to happen.

Assume that I click on H, E and C in that order. They had text and are now made invisible.
Next I click ADD with 1,2,3. What is the result? H=1, E=2 and C=3, or C=1, E=2 and H=3?
Anyway, you must make separate click events for all buttons. Very unfortunately there is no event for all buttons, where you could use the any blocks.

Cheers, Ghica

-- 
OK, I figured I don't need that anyways... I can always just make more buttons.


"Anyway, you must make separate click events for all buttons. Very unfortunately there is no event for all buttons, where you could use the any blocks."


So - you mean if I want to change the text color of a single button of the 12, but just set one rule for it, there's no way I can do that? I need to set a .click event for all the buttons separately?

Hope you got the gift I sent you, if not, please give me your paypal address.


-- 
You need to have a click event for all the buttons separately, but from then on you could call a generalized procedure that has the button clicked as an input argument.
By the way, you cannot make new buttons dynamically, but maybe that it not what you meant by "I can always make more buttons".
Cheers, Ghica.


-- 
Thanks
No, I meant in the designer


--

댓글 없음:

댓글 쓰기